Opened 15 years ago

Last modified 15 years ago

#12750 closed

Middleware snippet getting error in 1.2 alpha 1 - AttributeError: 'MethodDecoratorAdaptor' object has no attribute 'func_code — at Version 1

Reported by: Phoebe Bright Owned by: nobody
Component: Uncategorized Version: 1.2-alpha
Severity: Keywords: middleware, decorator
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Alex Gaynor)

Section of code causing error:

       from django.core.urlresolvers import resolve
        view_func, args, kwargs = resolve(request.META['PATH_INFO'])

         if hasattr(view_func,'view_func'):
            # it the view_func has a view_func then its a decorator
            co = view_func.view_func.func_code
        else:
            co = view_func.func_code   <---- fails here


Traceback:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 280, in run
    self.result = application(self.environ, self.start_response)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/servers/basehttp.py", line 672, in __call__
    return self.application(environ, start_response)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 245, in __call__
    response = middleware_method(request, response)
  File "/Users/phoebebr/Development/tinycomms/tinycomm/debug_middleware.py", line 117, in process_response
    co = view_func.func_code
AttributeError: 'MethodDecoratorAdaptor' object has no attribute 'func_code'
[01/Feb/2010 17:38:49] "GET /who/availability/ HTTP/1.1" 500 841

Change History (1)

comment:1 by Alex Gaynor, 15 years ago

Description: modified (diff)

Please use preview.

Note: See TracTickets for help on using tickets.
Back to Top