'can't set attribute' error on request.method = 'GET' in middleware.py line 42
arpegius opened this issue · 10 comments
I think this happens only for the newly created fb apps accordingly to this post http://developers.facebook.com/docs/canvas/post/. For my old application is all ok but for the one created yesterday (after December 10th as read in timeline) django raises this exception. Leave the request to POST, deleting this line, django raises the csrf exception due for the cross-origin post "CSRF token missing or incorrect".
Anyone else encountered this issue?
Thanks
Can you provide the stack trace that produced this exception?
Hi jgorset,
this is the traceback from django.
Environment:
Request Method: POST
Request URL: http://youonair.mapendo.me/tab/
Django Version: 1.3.1
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'comments',
'fandjango']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'fandjango.middleware.FacebookMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/var/Django-1.3.1/django/core/handlers/base.py" in get_response
-
File "/usr/local/lib/python2.6/dist-packages/fandjango/middleware.py" in process_request
response = middleware_method(request)
-
request.method = 'GET'
Exception Type: AttributeError at /tab/
Exception Value: can't set attribute
request.method
should be mutable, so I suspect a third-party library might be tinkering with your request
object. Please try removing the comments
application and see if that remedies the issue.
ok but comments is my django application that execute the application logic with only one function in views.py for now. i think the problem is related to the new Oauth2 authentication method, have you tried to create a new facebook application (after December 10th) and execute the authentication with fandjango last days? i've solved for now removing the line 42 in middleware.py, so leaving the post method, and adding @crsf_exempt to my view, but i know it's not a consistent solution.
Hope this helps to identify the problem. Thank you so much!
Thanks. I don't think we can attribute this issue to changes in Facebook's JavaScript SDK, but I'll verify your theory as time permits. Are you quite sure that you're not using any third-party libraries that might tinker with the request
object, though?
I'm pretty sure because my django project is just created and it's empty, only one view function, no models and no middleware installed, only fandjango. it could be a problem related to the server environment?
it could be a problem related to the server environment?
It could - what's your environment? You might quickly determine whether the environment the culprit by attempting to override the request method in your view and comparing the result of running the project on your development server and production server, respectively.
Ubuntu 9.04 Jaunty
Django Version: 1.3.1
Python Version: 2.6.2
MySql 5.0.75
Apache 2
mod-python
mods enabled in apache:
alias.conf authn_file.load authz_host.load autoindex.load deflate.load env.load mod_python.load php5.conf setenvif.conf ssl.load alias.load authz_default.load authz_user.load cgi.load dir.conf mime.conf negotiation.conf php5.load setenvif.load status.conf auth_basic.load authz_groupfile.load autoindex.conf deflate.conf dir.load mime.load negotiation.load python.load ssl.conf status.load
Thanks. I probably won't have the opportunity to mirror your environment, but I'll try to reproduce this issue with a new application sometime this weekend.
I haven't been able to reproduce this issue under Django 1.3.1 and Fandjango 3.7.4, @arpegius. Would you mind sending me the source code of your project?