Hi,

I encounter a error when I am using elixir and errorhandling.

    @errorhandling.dispatch_error.when("tg_exceptions is not None")
    def unhandled_exception(self, tg_source, tg_errors, tg_exception,
*args, **kw):
        cherrypy.response.status = 500
        return dict(tg_template="testbug.templates.error",
                title=_(u"500 Internal Server Error"),
tg_exception=unicode(tg_exception.message))

This is the error handling I am using. It works fine if I did not
login any user. But it throw an UnboundExecutionError if I login with
any user and encounter some exception throw by some function.

For example:

    @expose(template="testbug.templates.welcome")
    # @identity.require(identity.in_group("admin"))
    def index(self):
        import time
        assert 0, 'failed'
        # log.debug("Happy TurboGears Controller Responding For Duty")
        flash("Your application is now running")
        return dict(now=time.ctime())

Here, if I browse this page, it works fine. The error handler catch
exception and display them correctly. But once I browse this page with
any user I have created, I go error messages:

500 Internal error

The server encountered an unexpected condition which prevented it from
fulfilling the request.

Page handler: <bound method Root.index of <testbug.controllers.Root
object at 0x018ECDD0>>
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 "<string>", line 3, in index
  File "c:\python25\lib\site-packages\TurboGears-1.0.7-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.7-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.7-py2.5.egg
\turbogears\controllers.py", line 373, in <lambda>
    mapping, fragment, args, kw)))
  File "c:\python25\lib\site-packages\TurboGears-1.0.7-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.7-py2.5.egg
\turbogears\controllers.py", line 88, in _process_output
    fragment=fragment)
  File "c:\python25\lib\site-packages\TurboGears-1.0.7-py2.5.egg
\turbogears\view\base.py", line 161, 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 "C:\testbug\testbug\templates\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 [EMAIL PROTECTED] is not bound to a
Session; attribute refresh operation cannot proceed
Error in code generated from template file 'C:\\testbug\\testbug\
\templates\\error.kid'

Why the user instance is not bound to session? The master.kid display
information about user, e.g. user_name of user. Once the template
access the user instance, it throw that exception. I have no idea why
the user instance would be not bound to session after some exception
is throw and catch by the error handler.

I think it might be a bug, could someone help me sole this problem?

Thanks.

Victor Lin.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to