On Thursday, April 17, 2014 12:57:34 PM UTC-7, wilk wrote:
>
>
> Hi,
>
> For db connexion I use add_request_method with reify=True.
> In the end I commit only if this method was called.
>
> Now I use a tween and record the fact that the connexion was used or
> not, it's not a problem but I wonder if there is a way to directly know
> if a method was called (and reified) or not ?
>
> thanks
>
An alternative approach would be to add a finished callback inside the
reified method. Something like this:
def db_connection(req):
connection = ...
req.add_finished_callback(lambda r: connection.commit())
return connection
def main(...):
config.add_request_method(db_connection, reify=True)
Also, I think the standard advice is to use pyramid_tm for this kind of
thing, which implements logic similar to what you described.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.