On Jun 27, 6:42 pm, Ian Bicking <[EMAIL PROTECTED]> wrote:
> The way I see this working is something like (vaguely):
>
> def transaction_middleware(app):
> def wrapper(environ, start_response):
> manager = TransactionManager()
> environ['transaction.manager'] = manager
> try:
> app_iter = app(environ, start_response)
> except:
> manager.rollback()
> raise
> else:
> manager.commit()
>
> The manager is basically a container of *actual* transactions, and
> calling rollback or commit on it gets passed on to all the transactions
> in the manager.
this is fine. we're *really* starting to imitate J2EE in some ways.
but its not a bad thing.
>
> If you don't do anything that needs a transaction (e.g., read-only), you
> shouldn't put your transaction in the manager.
just to clarify, however this works, it should be *really easy* for
individual controller methods to be marked as "transactional" or not.
I have written decorators like these already, in the style of:
class MyController(...):
def index_page(self):
.....
@transactional
def post_message(self):
.....
def display_message(self):
.....
so id want that kind of thing to be readily available, i suppose it
would communicate with the WSGI middleware on a per-request basis.
but another thing i like, is that of the response to the request being
delivered *after* the transaction commits. i have raised this issue
on the pylons list before but i dont think i impressed anyone. if you
render your response template, then your transaction fails, you have
the potential for that response template to still be delivered with
the "success!" message. anyway, might be nice for the middleware to
address this if possible.
also i think this is all outside of the scope of SAContext. SAContext
should remain as a facade to SA-specific elements; it can accept
"strategy" objects which control its internal workings, so if need be
particular strategies can be delivered in order to function with the
transaction manager, without changing the external view of SAContext.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---