On Mon, Mar 30, 2009 at 2:23 PM, Robocop <btha...@physics.ucsd.edu> wrote:
> > So the fun continues. I realized that i did not need to use the > login_required decorator on this function since it's just tossed > around in the backend, so i took that out thinking it would prevent > decorators.py from being called. Did you take it out before even posting the code for timesheet_export? Because there is no evidence of that function being decorated with login_required in what you posted, which is a bit puzzling. > When i hit the function above now, > it posts the same error with a different request (can be viewed here > http://dpaste.com/21238/ ). The string object it's having trouble > with is this: > '/home/mipscomp/public_html/support/helpdesk/exported/03_30_09.txt > > I'm pretty confused at this point, as i've never seen this error > before. And the last time i recall working with this code, it worked > flawlessly. Ridicule and ideas are greatly appreciated. > The traceback is not so big it can't be posted: Traceback: File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.4/site-packages/django/contrib/auth/decorators.py" in __call__ 67. return self.view_func(request, *args, **kwargs) File "/home/mipscomp/public_html/support/helpdesk/projects/views.py" in audit_sheets_test 580. response = send_file(path,None, None) File "/usr/local/lib/python2.4/site-packages/django/contrib/auth/decorators.py" in __call__ 66. if self.test_func(request.user): Exception Type: AttributeError at /audit_sheets/TEST/ Exception Value: 'str' object has no attribute 'user' So, your code appears to be thinking it's calling a function called "send_file" and passing in a path argument (likely the string object you list above, as that quite looks like a path) but instead it jumps into decorator code. And the decorator code, instead of getting the request object it expects as its first arg, get this path string, and dies a horrible death trying to treat a string as a request object. So it looks like another case of improper decoration. You cannot just decorate arbitrary functions with @login_requried -- it expects to be used specifically with view functions, that always get request as their first argument. If you decorate some other function that doesn't take a request as a first argument, you get errors like what you are reporting. Karen --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---