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 #1118 (closed defect: fixed)

Opened 13 years ago

Last modified 12 years ago

@validate with SQLAlchemy without delegating error handling leads to incomprehensible tracebacks on error

Reported by: jnf Owned by: anonymous
Priority: normal Milestone: 1.0
Component: TurboGears Version:
Severity: normal Keywords: validate, SQLAlchemy, dispatch_error


Version: 1.0b1 (not available to select)

As described in  http://groups.google.com/group/turbogears/msg/fe8a944475b6aaa9 I get a strange trace back if I do the following:

(1) I've quickstarted a project "testerrsa" using SQLAlchemy and without identity.

(2) I've changed class Root in controllers.py to:

class Root(controllers.RootController):
    @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
Traceback (most recent call last):
/_cphttptools.py", line 105, in _run
/_cphttptools.py", line 254, in main
    body = page_handler(*virtual_path, **self.params)
  File "<string>", line 3, in index
ears/controllers.py", line 326, in expose
    output = database.run_with_transaction(
  File "<string>", line 5, in run_with_transaction
ears/database.py", line 292, in sa_rwt
    retval = dispatch_exception(e,args,kw)
ears/database.py", line 269, in dispatch_exception
    return errorhandling.dispatch_error(
TypeError: dispatch_error() got multiple values for keyword argument

If I do the same with SQLObject I get a traceback referring to my "NameError?", which is what I'd expect for SQLAlchemy as well. (In the ML posting I refer to, the SQLObject version has a typo, tg_error instead of tg_errors. Fixing this didn't make a difference.)

(Part of) the reason seems to lie in database.py: 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 fixes the problem for me. I'm not sure about side effects.

Someone with a deeper knowledge should try to find out if it's OK to use raise here and why dispatch_error() gets multiple values for keyword argument 'tg_errors'...

Change History

comment:1 Changed 13 years ago by jnf

  • Type changed from task to defect

comment:2 Changed 13 years ago by alberto

Can you try [1895] to see if it's fixed?

Thanks, Alberto

comment:3 Changed 13 years ago by jnf

Yes, it's fixed in both, my small sample test case and the original code where I found the problem. Thanks for your help! Can you commit your change to svn?

Cheers, -jnf

comment:4 Changed 13 years ago by alberto

  • Status changed from new to closed
  • Resolution set to fixed

I'ts already commited ;) Glad it worked. I'll close the ticket then.


Note: See TracTickets for help on using tickets.