Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old style streaming responses no longer supported in Django 1.7 #2

Open
frewsxcv opened this issue Sep 13, 2014 · 3 comments
Open

Old style streaming responses no longer supported in Django 1.7 #2

frewsxcv opened this issue Sep 13, 2014 · 3 comments

Comments

@frewsxcv
Copy link

https://github.com/educreations/django-piston/blob/master/piston/resource.py#L246

django/django@8b9b8d3#diff-eeebc8cb56240caf13a9952431189fef

Blocking us from upgrading to Django 1.7

@streeter
Copy link
Member

Ugh, sad face.

@frewsxcv
Copy link
Author

I think we should be able to replace:

    @staticmethod
    def _use_emitter(result):
        """True iff result is a HttpResponse and contains non-string content."""
        if not isinstance(result, HttpResponse):
            return False
        elif django.VERSION >= (1, 4):
            return result._base_content_is_iter
        else:
            return not result._is_string

with

    @staticmethod
    def _use_emitter(result):
        """True iff result is a HttpResponse and contains non-string content."""
        return isinstance(result, HttpResponse)

Since:

  1. We don't care about django.VERSION < (1, 4)
  2. Since HttpStreamingResponse is not a subclass of HttpResponse (it's a subclass of HttpResponseBase), we should always expect HttpResponse to contain string content (I think)

@frewsxcv
Copy link
Author

I take back what I wrote previously in the code block. Since HttpResponse should always return string content, that method should always return False

    @staticmethod
    def _use_emitter(result):
        """True iff result is a HttpResponse and contains non-string content."""
        return False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants