Frank Burkhardt wrote:
> Hi,
> 
> when I raise an exception in a view, no changes done to the any object
> are saved to zodb.
> 
> I would like to change that for a single object:
> 
> class MyView(BrowserView):
>    def __call__(self):
>       [...]
>       if some_test:
           transaction.abort()
>          save_object(self.context)
           transaction.commit()
>          raise MyException()
>       [...]
> 
> No other object should be saved - just self.context. How could I do that?

You can do this by explicitly rolling back the current transaction,
modifying that single object and committing the transaction so that just
those changes will be saved. Then you raise the exception and let Zope
do its things (which, among others, include rolling back the now pretty
much empty transaction).

HTH

Philipp

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to