RE: [Zope] transaction control from Zope to Postgresql?
What DA are you using? I use PoPy and ZPoPyDA. It appears (I haven't verified it) that it rolls back all the ZSQLMethods executed between pageviews. Troy -----Original Message----- From: Reinoud van Leeuwen [mailto:reinoud@xs4all.nl] Sent: Friday, June 08, 2001 6:40 AM To: zope@zope.org Subject: [Zope] transaction control from Zope to Postgresql? Hello world, I am in need for a way to explicitely contral transaction behaviour for a group of inserts in a postgresql database. The DTML script I use first inserts a header record and after that some detail records. The postgresql function that does the inserts might return an errorstring. So I tried the following code (simplified for readability) <dtml-try> <dtml-call "sql_to_insert_head_record (some_parameters)"> <dtml-in "a_loop_over_detail_lines"> <dtml-if "check_detail_line"> <dtml-raise required_attribute_missing> errormessage </dtml-raise> </dtml-if> <dtml-call "sql_to_insert_detail_line"> <dtml-if "check_returncode"> <dtml-raise inserterror> error inserting! </dtml-raise> </dtml-if> </dtml-in> <dtml-except> insert failed (error: <dtml-var error_value>) <dtml-else> object added to database </dtml-try> What I would like to do is that all the SQL executed between dtml-try and dtml-except is rolled back when the exception is raised. I tried sending "begin" and "rollback" to the database, but that does not work because Zope sends some transaction control by itself. I tried getting get_transaction().begin() and get_transaction().abort() to work, but I cannot reach that function from dtml not python script. Anyone has some clues to spare? Have a nice weekend, Reinoud _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Fri, 8 Jun 2001 11:32:31 -0500, you wrote:
What DA are you using? I use PoPy and ZPoPyDA. It appears (I haven't verified it) that it rolls back all the ZSQLMethods executed between pageviews.
I use the PygreSQL connector. Do you expect that they behave different? Th documentation suggests that Zope is the one that is doing transaction control... (but I'll try it against PoPy and ZPoPyDA) -- __________________________________________________ "Nothing is as subjective as reality" Reinoud van Leeuwen reinoud@xs4all.nl http://www.xs4all.nl/~reinoud __________________________________________________
participants (2)
-
Farrell, Troy -
reinoud@xs4all.nl