Hi,

I'm using TurboGears 1.0b1. I've run into a problem when using
validation with SQLAlchemy.

Test cases:

SQLObject:

(1) I've quickstarted a project "testerrso" using SQLObject and without
    identity.
(2) I've changed class Root in controllers.py to:

class Root(controllers.RootController):
    @expose(template="testerrso.templates.welcome")
    @validate(validators = {'v': turbogears.validators.Int})
    def index(self, tg_error=None, **kwargs):
        raise NameError
        import time
        log.debug("Happy TurboGears Controller Responding For Duty")
        return dict(now=time.ctime())

(3) When directing my browser to the test app I get a traceback that
    references my raise NameError => OK.

SQLAlchemy:

(1) I've quickstarted a project "testerrsa" using SQLObject and without
    identity.
(2) I've changed class Root in controllers.py to:

class Root(controllers.RootController):
    @expose(template="testerrsa.templates.welcome")
    @validate(validators = {'v': turbogears.validators.Int})
    def index(self, tg_errors=None, **kwargs):
        raise NameError
        import time
        log.debug("Happy TurboGears Controller Responding For Duty")
        return dict(now=time.ctime())

(3) When directing my browser to the test app I get a traceback that
    looks like this:

Page handler: <bound method Root.index of <testerrsa.controllers.Root
object at
0x40b1ea6c>>
Traceback (most recent call last):
  File
"/usr/local/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy
/_cphttptools.py", line 105, in _run
    self.main()
  File
"/usr/local/lib/python2.4/site-packages/CherryPy-2.2.1-py2.4.egg/cherrypy
/_cphttptools.py", line 254, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in index
  File
"/usr/local/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbog
ears/controllers.py", line 326, in expose
    output = database.run_with_transaction(
  File "<string>", line 5, in run_with_transaction
  File
"/usr/local/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbog
ears/database.py", line 292, in sa_rwt
    retval = dispatch_exception(e,args,kw)
  File
"/usr/local/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbog
ears/database.py", line 269, in dispatch_exception
    return errorhandling.dispatch_error(
TypeError: dispatch_error() got multiple values for keyword argument
'tg_errors'

Obviously my real exception becomes unrecognizable.

As far as I can suspect without digging too deep into the internals this
is somehow connected to so_rwt (database.py) just doing

[...]
        try:
            retval = func(*args, **kw)
[...]
        except:
[...]
            raise
[...]

and sa_rwt (same file) doing

[...]
    try:
        retval = func(*args, **kw)
[...]
    except Exception, e:
        transaction.rollback()
        retval = dispatch_exception(e,args,kw)
[...]

=> so_rwt just re-raises the exception, sa_rwt dispatches it. I'm not
too much into things to understand the reason for this differing
behaviour. Anyway, using a "raise" in sa_rwt as will fixes the
problem for me. I'm not sure about side effects.

Should I open a ticket in trac, or is there something I'm missing?

Cheers,
  --Jan Niklas

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to