On Fri, May 10, 2013 at 8:55 AM, Tom Evans <[email protected]> wrote:
> On Fri, May 10, 2013 at 2:52 PM, Larry Martell <[email protected]> 
> wrote:
>> Just upgraded to 1.5 and my app is failing with:
>>
>> Internal Server Error:
>> Traceback (most recent call last):
>> File "/Library/Python/2.7/site-packages/django/core/handlers/base.py",
>> line 187, in get_response
>>      response = middleware_method(request, response)
>>    File 
>> "/Library/Python/2.7/site-packages/django/contrib/sessions/middleware.py",
>> line 26, in process_response
>>      patch_vary_headers(response, ('Cookie',))
>>    File "/Library/Python/2.7/site-packages/django/utils/cache.py",
>> line 142, in patch_vary_headers
>>      if response.has_header('Vary'):
>>  [error] AttributeError: 'function' object has no attribute 'has_header'
>>
>> My code that is triggering this:
>>
>> if report_response.has_header('Content-disposition'):
>>
>> I didn't see anything in the docs that said this method was being
>> removed from the HttpResponse class.
>>
>
> It hasn't. If you look at the exception message closely, you will see
> that it does not say "HttpResponse object has no attribute ...", it
> says "function object has no attribute ...". Somehow, this middleware
> is receiving a function instead of a response object.
>
>> Anyone know how I can fix this so I can use 1.5?
>>
>
> The full stack trace may explain more, but then again maybe not - the
> exception happens in middleware processing, but the error is returning
> a function instead of a HttpResponse object in the content generation
> phase (ie in the view). You will probably need to look closely at each
> function the request passes through on this particular request, and
> work out where the bogus return value is coming from.

That is the full stack trace. I have just one piece of middleware:

import re
class LastSiteUrl(object):

    def is_admin_url(self, url):
        if re.search('^(http:\/\/.*){0,1}\/admin\/', url) is None: return(False)
        else: return(True)

    def process_request(self, request):
        if self.is_admin_url(request.path) and \
            not self.is_admin_url(request.META['HTTP_REFERER']):
            request.session['last_site_url'] = request.META['HTTP_REFERER']

I don't see how that could be causing this. What changed in 1.5 to
break this? In 1.4 I do not get this error with the same middleware.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to