#2222: Got UnboundExecutionError when the user is loged in and there is
exception
raised within method with exception_handler
------------------------+---------------------------------------------------
Reporter: victorlin | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 1.1
Component: TurboGears | Version: 1.0.8
Severity: normal | Keywords: session identity error handler
------------------------+---------------------------------------------------
Page handler: <function _wrapper at 0x020DF230>
Traceback (most recent call last):
File "c:\python25\lib\site-
packages\cherrypy-2.3.0-py2.5.egg\cherrypy\_cphttptools.py", line 121, in
_run
self.main()
File "c:\python25\lib\site-
packages\cherrypy-2.3.0-py2.5.egg\cherrypy\_cphttptools.py", line 264, in
main
body = page_handler(*virtual_path, **self.params)
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\identity\conditions.py",
line 241, in _wrapper
return fn(*args, **kw)
File "<string>", line 3, in add
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\controllers.py", line 360,
in expose
*args, **kw)
File "<string>", line 5, in run_with_transaction
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\database.py", line 407, in
sa_rwt
retval = func(*args, **kw)
File "<string>", line 5, in _expose
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\controllers.py", line 373,
in <lambda>
mapping, fragment, args, kw)))
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\controllers.py", line 410,
in _execute_func
output = errorhandling.try_call(func, *args, **kw)
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\errorhandling.py", line 92,
in try_call
output = dispatch_error(self, func, None, e, *args, **kw)
File "<string>", line 5, in dispatch_error
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\errorhandling.py", line 69,
in adaptor
return func(controller, *args, **kw)
File "<string>", line 3, in add_form
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\controllers.py", line 355,
in expose
*args, **kw)
File "<string>", line 5, in _expose
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\controllers.py", line 373,
in <lambda>
mapping, fragment, args, kw)))
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\controllers.py", line 423,
in _execute_func
return _process_output(output, template, format, content_type,
mapping, fragment)
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\controllers.py", line 88,
in _process_output
fragment=fragment)
File "c:\python25\lib\site-
packages\TurboGears-1.0.8-py2.5.egg\turbogears\view\base.py", line 159, in
render
return engine.render(**kw)
File "c:\python25\lib\site-
packages\TurboKid-1.0.4-py2.5.egg\turbokid\kidsupport.py", line 206, in
render
output=output, format=format)
File "c:\python25\lib\site-
packages\kid-0.9.6-py2.5.egg\kid\__init__.py", line 301, in serialize
raise_template_error(module=self.__module__)
File "c:\python25\lib\site-
packages\kid-0.9.6-py2.5.egg\kid\__init__.py", line 299, in serialize
return serializer.serialize(self, encoding, fragment, format)
File "C:\Python25\lib\site-
packages\kid-0.9.6-py2.5.egg\kid\serialization.py", line 107, in serialize
text = ''.join(self.generate(stream, encoding, fragment, format))
File "C:\Python25\lib\site-
packages\kid-0.9.6-py2.5.egg\kid\serialization.py", line 629, in generate
for ev, item in self.apply_filters(stream, format):
File "C:\Python25\lib\site-
packages\kid-0.9.6-py2.5.egg\kid\serialization.py", line 165, in
format_stream
for ev, item in stream:
File "c:\python25\lib\site-packages\kid-0.9.6-py2.5.egg\kid\parser.py",
line 221, in _coalesce
for ev, item in stream:
File "C:\Python25\lib\site-
packages\kid-0.9.6-py2.5.egg\kid\serialization.py", line 477, in
inject_meta_tags
for ev, item in stream:
File "c:\python25\lib\site-packages\kid-0.9.6-py2.5.egg\kid\parser.py",
line 179, in _track
for p in stream:
File "c:\python25\lib\site-packages\kid-0.9.6-py2.5.egg\kid\filter.py",
line 41, in apply_matches
templates[:i] + templates[i+1:], apply_func):
File "c:\python25\lib\site-packages\kid-0.9.6-py2.5.egg\kid\filter.py",
line 32, in apply_matches
item = stream.expand()
File "c:\python25\lib\site-packages\kid-0.9.6-py2.5.egg\kid\parser.py",
line 108, in expand
for ev, item in self._iter:
File "c:\python25\lib\site-packages\kid-0.9.6-py2.5.egg\kid\parser.py",
line 179, in _track
for p in stream:
File "c:\python25\lib\site-packages\kid-0.9.6-py2.5.egg\kid\parser.py",
line 221, in _coalesce
for ev, item in stream:
File "I:\projects\amazon_winner\src\trunk\amazon-
winner\amazon_winner\templates\super_admin\master.py", line 110, in
_match_func
File "c:\python25\lib\site-
packages\SQLAlchemy-0.5.0beta2-py2.5.egg\sqlalchemy\orm\attributes.py",
line 123, in __get__
return self.impl.get(instance_state(instance))
File "c:\python25\lib\site-
packages\SQLAlchemy-0.5.0beta2-py2.5.egg\sqlalchemy\orm\attributes.py",
line 307, in get
value = callable_()
File "c:\python25\lib\site-
packages\SQLAlchemy-0.5.0beta2-py2.5.egg\sqlalchemy\orm\attributes.py",
line 870, in __call__
attr.impl.key in unmodified
File "c:\python25\lib\site-
packages\SQLAlchemy-0.5.0beta2-py2.5.egg\sqlalchemy\orm\mapper.py", line
1602, in _load_scalar_attributes
raise sa_exc.UnboundExecutionError("Instance %s is not bound to a
Session; attribute refresh operation cannot proceed" % (state_str(state)))
UnboundExecutionError: Instance u...@0x20e2b30 is not bound to a Session;
attribute refresh operation cannot proceed
Error in code generated from template file
'I:\\projects\\amazon_winner\\src\\trunk\\amazon-
winner\\amazon_winner\\templates\\super_admin\\user_form.kid'
I use elixir as database backend. I got this error when I login as a user,
and I browse some exposed method that raise exception and handled by
exception handler. The exception handler's template access identity,
namely, a elixir entity. I thought things happen like this.
session created
call page handler
handle...
raise a exception (the session might be closed here)
handle error
dispatch to error handler
session created (another session)
call page handler
render page, the template access identity object(the session is closed)...
Boom!
That's it, I thought the identity create some object with old session is
closed when there is a exception raised. And the error handler catch the
problem and render it, but the template will display the user information,
once it touch the closed session's identity, here comes the error.
But however, that is just a guess. I'm not sure is that correct.
This is the workaround recipe, I enforce the SqlAlchemyIdentity to return
fresh user every time rather than stored one.
{{{
from turbogears.identity import saprovider
def _get_user(self):
if self.visit_link is None:
return None
return saprovider.user_class.query.get(self.visit_link.user_id)
saprovider.SqlAlchemyIdentity.user = property(_get_user)
}}}
--
Ticket URL: <http://trac.turbogears.org/ticket/2222>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---