On 11/17/05, Sean Cazzell <[EMAIL PROTECTED]> wrote:
> def in_transaction(func):
>     hub = AutoConnectHub()
>     def newfunc(*args, **kw):
>         hub.begin()
>         try:
>             func(*args, **kw)
>         except cherrypy.HTTPRedirect:
>             hub.commit()
>             raise
>         except:
>             hub.rollback()
>             raise
>         else:
>             hub.commit()
>     newfunc.func_name = func.func_name
>     newfunc.func_doc = func.func_doc
>     return newfunc
>
> The expose decorator will check the config / it's parameters and if a
> transaction is desired it will wrap itself in the in_transaction
> decorator.

Unfortunately, it really needs to use the hub that's in use by the
model classes... from a random model.py:

__connection__ = AutoConnectHub()
# (or PackageHub)

class Foo(SQLObject):
    ...

In a multi-application world, it'll be possible to have different
parts of a site going to different databases. that won't be the common
case, though.

Sticking to the common case, we just need a nice way to get ahold of
the hub in question. There are probably a small handful of ways we
could find the model module and get the hub from it. Unfortunately,
I'm out of time for exploring that now, and I'll be offline for a
while. I hope I'll be able to get back online at least briefly later
today...

Kevin

Reply via email to