[Django Code] #5920: Error AttributeError: 'function' object has no attribute 'status_code' in 6668 version

200 views
Skip to first unread message

Django Code

unread,
Nov 11, 2007, 2:13:12 PM11/11/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5920: Error AttributeError: 'function' object has no attribute 'status_code' in
6668 version
-----------------------+----------------------------------------------------
Reporter: aaloy | Owner: nobody
Status: new | Component: Uncategorized
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
-----------------------+----------------------------------------------------
This error appears in the last trunk, it not appears in 6473 version and I
don't get it in all pages.

{{{
Traceback (most recent call last):
File "/usr/lib/python2.5/site-packages/django/core/servers/basehttp.py",
line 278, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/python2.5/site-packages/django/core/servers/basehttp.py",
line 620, in __call__
return self.application(environ, start_response)
File "/usr/lib/python2.5/site-packages/django/core/handlers/wsgi.py",
line 209, in __call__
response = middleware_method(request, response)
File "/usr/lib/python2.5/site-packages/django/middleware/gzip.py", line
14, in process_response
if response.status_code != 200 or len(response.content) < 200:
}}}

--
Ticket URL: <http://code.djangoproject.com/ticket/5920>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines

Django Code

unread,
Nov 11, 2007, 3:53:13 PM11/11/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5920: Error AttributeError: 'function' object has no attribute 'status_code' in
6668 version
---------------------+------------------------------------------------------
Reporter: aaloy | Owner: nobody
Status: new | Component: Uncategorized
Version: SVN | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
---------------------+------------------------------------------------------
Changes (by aaloy):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0

Comment:

It seems the issue is not with http but with the cache_page decorator. The
decorator worked with the previos version and does not work with the trunk
versions.

This worke on version 6473
{{{
def ajax_zonas(request):
"""Get all ojects from table Provincia odrdereb by name"""
listado = Provincia.objects.all().order_by('name')
json = serialize('json', listado,ensure_ascii=True)
return HttpResponse(json, mimetype='text/javascript')
ajax_zonas = cache_page(ajax_zonas, 60)
}}}

--
Ticket URL: <http://code.djangoproject.com/ticket/5920#comment:1>

Django Code

unread,
Mar 6, 2008, 11:18:50 AM3/6/08
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5920: Error AttributeError: 'function' object has no attribute 'status_code' in
6668 version
----------------------+-----------------------------------------------------
Reporter: aaloy | Owner: nobody
Status: closed | Component: Uncategorized
Version: SVN | Resolution: invalid
Keywords: | Stage: Unreviewed
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
----------------------+-----------------------------------------------------
Changes (by guettli):

* status: new => closed
* resolution: => invalid

Comment:

No feedback since several months. Closing it, since some people said
'worksforme'.

Please reopen if problem still happens with current SVN trunk.

--
Ticket URL: <http://code.djangoproject.com/ticket/5920#comment:3>

Django Code

unread,
Mar 14, 2008, 12:30:50 PM3/14/08
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5920: Error AttributeError: 'function' object has no attribute 'status_code' in
6668 version
------------------------+---------------------------------------------------
Reporter: aaloy | Owner: nobody
Status: reopened | Component: Cache system
Version: SVN | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
------------------------+---------------------------------------------------
Changes (by MihaiD):

* status: closed => reopened
* resolution: invalid =>
* component: Uncategorized => Cache system

Comment:

This still doesn't seem to work in the svn trunk. I get the following
error:

Traceback (most recent call last):

File "G:\Python25\lib\site-packages\django\core\servers\basehttp.py",
line 277, in run
self.result = application(self.environ, self.start_response)

File "G:\Python25\lib\site-packages\django\core\servers\basehttp.py",
line 631, in __call__
return self.application(environ, start_response)

File "G:\Python25\lib\site-packages\django\core\handlers\wsgi.py", line
209, in __call__
response = middleware_method(request, response)

File "G:\Python25\lib\site-packages\django\middleware\common.py", line
90, in process_response
if response.status_code == 404:

AttributeError: 'function' object has no attribute 'status_code'

I use cache_page in urls.py. Using @cache_page in views seems to work
though (or at least no errors were generated).
I have the following middleware set:

MIDDLEWARE_CLASSES = (
'django.middleware.cache.CacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
)

I couldn't determine if CacheMiddleware was needed for individual views or
not so I've tested with and without it, with the same result.

--
Ticket URL: <http://code.djangoproject.com/ticket/5920#comment:4>

Django Code

unread,
Mar 16, 2008, 11:04:29 AM3/16/08
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5920: Error AttributeError: 'function' object has no attribute 'status_code' in
6668 version
------------------------+---------------------------------------------------
Reporter: aaloy | Owner: nobody
Status: reopened | Component: Cache system
Version: SVN | Resolution:
Keywords: | Stage: Accepted
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
------------------------+---------------------------------------------------
Changes (by MihaiD):

* stage: Unreviewed => Accepted

--
Ticket URL: <http://code.djangoproject.com/ticket/5920#comment:5>

Django Code

unread,
Mar 18, 2008, 9:46:53 PM3/18/08
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5920: Error AttributeError: 'function' object has no attribute 'status_code' in
6668 version
---------------------+------------------------------------------------------
Reporter: aaloy | Owner: ramiro
Status: new | Component: Cache system
Version: SVN | Resolution:
Keywords: | Stage: Accepted
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
---------------------+------------------------------------------------------
Changes (by ramiro):

* owner: nobody => ramiro
* status: reopened => new

--
Ticket URL: <http://code.djangoproject.com/ticket/5920#comment:6>

Django Code

unread,
Mar 18, 2008, 11:29:27 PM3/18/08
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#5920: Error AttributeError: 'function' object has no attribute 'status_code' in
6668 version
------------------------+---------------------------------------------------
Reporter: aaloy | Owner: ramiro
Status: assigned | Component: Cache system
Version: SVN | Resolution:
Keywords: | Stage: Accepted
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
------------------------+---------------------------------------------------
Changes (by ramiro):

* status: new => assigned

Comment:

@MihaiD: I have been able to reproduce the problem by using
{{{cache_page}}} in the URLconf as you describe but by using the string
syntax for the view being "decorated" instead of the callable syntax (see
http://www.djangoproject.com/documentation/release_notes_0.96/#urlconf-
improvements). This confuses
{{{django.utils.decorators.decorator_from_middleware()}}} than then ends
pushing a stub function as a decorator/middleware method parameter in a
place where a !HttpResponse is expected.

{{{
#!python

import views

urlpatterns = patterns('',
(r'^foo/$', cache_page('myproj.myapp.views.myview')), # This is WRONG
(r'^foo/$', cache_page(views.myview)), # This is OK
)
}}}

Can you confirm this is what you are doing in your setup?. If so, I will
then change Component field of this ticket to ''Documentation'' and will
submit a patch against the URL dispatcher docs to clarify this.

--
Ticket URL: <http://code.djangoproject.com/ticket/5920#comment:7>
Reply all
Reply to author
Forward
0 new messages