Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2338 (closed defect: migrated)

Opened 10 years ago

Last modified 8 years ago

auth information unavailable in the error template

Reported by: pitrou Owned by:
Priority: normal Milestone: 2.1
Component: TurboGears Version: 2.0b7
Severity: normal Keywords:
Cc:

Description

It seems that, when generating a 404 page (or, I assume, any other error page), the ORM session has been invalidated and therefore any attempt by the basic layout template (which is inherited by the error template) to access attributes of the current user (e.g. tg.identity user?.foobar) produce the following traceback.

Reading  http://turbogears.org/2.0/docs/main/RequestFlow.html, it may be due to the Database Session Manager cleaning up the session before the Error Middleware builds the error page.

For reference, this is the exception I got:

Exception happened during processing of request from ('127.0.0.1',
39054)
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/Paste-1.7.2-py2.6.egg/paste/
httpserver.py", line 1062, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib64/python2.6/SocketServer.py", line 320, in
finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib64/python2.6/SocketServer.py", line 615, in __init__
    self.handle()
  File "/usr/lib/python2.6/site-packages/Paste-1.7.2-py2.6.egg/paste/
httpserver.py", line 436, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib64/python2.6/BaseHTTPServer.py", line 329, in handle
    self.handle_one_request()
  File "/usr/lib/python2.6/site-packages/Paste-1.7.2-py2.6.egg/paste/
httpserver.py", line 431, in handle_one_request
    self.wsgi_execute()
  File "/usr/lib/python2.6/site-packages/Paste-1.7.2-py2.6.egg/paste/
httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/usr/lib/python2.6/site-packages/Paste-1.7.2-py2.6.egg/paste/
cascade.py", line 130, in __call__
    return self.apps[-1](environ, start_response)
  File "/usr/lib/python2.6/site-packages/Paste-1.7.2-py2.6.egg/paste/
registry.py", line 350, in __call__
    app_iter = self.application(environ, start_response)
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
middleware.py", line 214, in __call__
    self.app, new_environ, catch_exc_info=True)
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
util.py", line 94, in call_wsgi_application
    app_iter = application(environ, start_response)
  File "/usr/lib/python2.6/site-packages/WebError-0.10.1-py2.6.egg/
weberror/evalexception.py", line 235, in __call__
    return self.respond(environ, start_response)
  File "/usr/lib/python2.6/site-packages/WebError-0.10.1-py2.6.egg/
weberror/evalexception.py", line 418, in respond
    return self.application(environ, start_response)
  File "/usr/lib/python2.6/site-packages/TurboGears2-2.0-py2.6.egg/tg/
configuration.py", line 643, in wrapper
    return app(environ, start_response)
  File "/usr/lib/python2.6/site-packages/TurboGears2-2.0-py2.6.egg/tg/
configuration.py", line 543, in remover
    return app(environ, start_response)
  File "/usr/lib/python2.6/site-packages/repoze.tm2-1.0a4-py2.6.egg/
repoze/tm/__init__.py", line 19, in __call__
    result = self.application(environ, save_status_and_headers)
  File "/usr/lib/python2.6/site-packages/repoze.who-1.0.10-py2.6.egg/
repoze/who/middleware.py", line 49, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.6/site-packages/ToscaWidgets-0.9.4-py2.6.egg/
tw/core/middleware.py", line 36, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python2.6/site-packages/ToscaWidgets-0.9.4-py2.6.egg/
tw/core/middleware.py", line 59, in wsgi_app
    resp = req.get_response(self.application)
  File "/usr/lib/python2.6/site-packages/WebOb-0.9.6.1-py2.6.egg/webob/
__init__.py", line 1325, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/python2.6/site-packages/WebOb-0.9.6.1-py2.6.egg/webob/
__init__.py", line 1293, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/python2.6/site-packages/ToscaWidgets-0.9.4-py2.6.egg/
tw/core/resource_injector.py", line 67, in _injector
    resp = req.get_response(app)
  File "/usr/lib/python2.6/site-packages/WebOb-0.9.6.1-py2.6.egg/webob/
__init__.py", line 1325, in get_response
    application, catch_exc_info=False)
  File "/usr/lib/python2.6/site-packages/WebOb-0.9.6.1-py2.6.egg/webob/
__init__.py", line 1293, in call_application
    app_iter = application(self.environ, start_response)
  File "/usr/lib/python2.6/site-packages/Beaker-1.3-py2.6.egg/beaker/
middleware.py", line 81, in __call__
    return self.app(environ, start_response)
  File "/usr/lib/python2.6/site-packages/Beaker-1.3-py2.6.egg/beaker/
middleware.py", line 160, in __call__
    return self.wrap_app(environ, session_start_response)
  File "/usr/lib/python2.6/site-packages/Routes-1.10.3-py2.6.egg/
routes/middleware.py", line 130, in __call__
    response = self.app(environ, start_response)
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
wsgiapp.py", line 125, in __call__
    response = self.dispatch(controller, environ, start_response)
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
wsgiapp.py", line 324, in dispatch
    return controller(environ, start_response)
  File "/home/antoine/ftth/XXX/XXX/lib/base.py", line 36, in __call__
    return TGController.__call__(self, environ, start_response)
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
controllers/core.py", line 221, in __call__
    response = self._dispatch_call()
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
controllers/core.py", line 172, in _dispatch_call
    response = self._inspect_call(func)
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
controllers/core.py", line 107, in _inspect_call
    result = self._perform_call(func, args)
  File "/usr/lib/python2.6/site-packages/TurboGears2-2.0-py2.6.egg/tg/
controllers.py", line 798, in _perform_call
    self, controller, params, remainder=remainder)
  File "/usr/lib/python2.6/site-packages/TurboGears2-2.0-py2.6.egg/tg/
controllers.py", line 172, in _perform_call
    response = self._render_response(controller, output)
  File "/usr/lib/python2.6/site-packages/TurboGears2-2.0-py2.6.egg/tg/
controllers.py", line 350, in _render_response
    template_name=template_name)
  File "/usr/lib/python2.6/site-packages/TurboGears2-2.0-py2.6.egg/tg/
render.py", line 141, in render
    return render_function(template_name, template_vars, **kwargs)
  File "/usr/lib/python2.6/site-packages/TurboGears2-2.0-py2.6.egg/tg/
render.py", line 179, in render_mako
    **kwargs)
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
templating.py", line 274, in render_mako
    cache_type=cache_type, cache_expire=cache_expire)
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
templating.py", line 249, in cached_template
    return render_func()
  File "/usr/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/
templating.py", line 271, in render_template
    return literal(template.render_unicode(**globs))
  File "/usr/lib/python2.6/site-packages/Mako-0.2.4-py2.6.egg/mako/
template.py", line 138, in render_unicode
    return runtime._render(self, self.callable_, args, data,
as_unicode=True)
  File "/usr/lib/python2.6/site-packages/Mako-0.2.4-py2.6.egg/mako/
runtime.py", line 347, in _render
    _render_context(template, callable_, context, *args,
**_kwargs_for_callable(callable_, data))
  File "/usr/lib/python2.6/site-packages/Mako-0.2.4-py2.6.egg/mako/
runtime.py", line 364, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/lib/python2.6/site-packages/Mako-0.2.4-py2.6.egg/mako/
runtime.py", line 397, in _exec_template
    callable_(context, *args, **kwargs)
  File "_home_antoine_ftth_XXX_XXX_templates_layout_mak", line 77, in
render_body
  File "/home/antoine/ftth/XXX/XXX/model/auth.py", line 157, in cps
    return set(z.cp for g in self.groups for z in g.zones)
  File "/home/antoine/ftth/XXX/XXX/model/auth.py", line 157, in
<genexpr>
    return set(z.cp for g in self.groups for z in g.zones)
  File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/
sqlalchemy/orm/attributes.py", line 158, in __get__
    return self.impl.get(instance_state(instance), instance_dict
(instance))
  File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/
sqlalchemy/orm/attributes.py", line 374, in get
    value = callable_()
  File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/
sqlalchemy/orm/strategies.py", line 538, in __call__
    (mapperutil.state_str(state), self.key)
UnboundExecutionError: Parent instance <Group at 0x3ec76d0> is not
bound to a Session; lazy load operation of attribute 'zones' cannot
proceed

Change History

comment:1 Changed 10 years ago by jorge.vargas

  • Milestone set to 2.1

comment:2 Changed 8 years ago by pedersen

  • Status changed from new to closed
  • Resolution set to migrated
Note: See TracTickets for help on using tickets.