On Aug 17, 7:17 am, Christoph Haas <[EMAIL PROTECTED]> wrote:
> Does that mean I still have to run Session.commit() manually after I did
> changes? I'm glad about the "autoflush" option so I don't need to flush
> any more. But instead it appears I need to commit() after every change.
> Shouldn't Pylons flush the Session automatically when a request is done?
> Would it be wise to add a "model.Session.commit()" to the lib/base.py ->
> BaseController -> __after__()?
this could be done, yes. however, for the purposes of the tutorial, i
think its better that the commit() is manual to start with, because a
commit() in all cases might be unexpected. particularly if the
controller wishes to display an error on the page and not actually
persist changes - in that case you might not want the commit().
basically, the basic controller idea here does not address any sort of
generic way of handling "success/fail" conditions, like with an
exception throw or similar. so i think commit()-in-all-cases might
assume too much, and if users want to reduce the number of explicit
commit() calls, they should choose how they want to do that.
my own preference is using a @transact decorator that inspects the
".errors" attribute of the controller before committing (otherwise it
rolls back).
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---