On Wed, 26 Dec 2001 00:30:40 -0500, Edmund Lian wrote: >I'm wondering how MiddleKit users are dealing with the issue of >transactions. As far as I can tell, the notion of commits and >rollbacks are >not fully implemented in ObjectStore.py--methods like >revertChanges(self) >raise NotImplemented errors). > >Why I ask is because I'm used to the traditional RDBMS notions of >transactions (and ACIDity) and not at all used to using an >object-relational layer. I think that there might be situations >where one >wants to commit several objects to persistant storage atomically, but >without support for transactions in MiddleKit (or MySQL for that >matter), >how does everybody cope? Do you really drop down to unwinding your >..saveChanges() method calls by hand (i.e., with code)? Isn't this a >bit >icky?
Tip: If you want to have very simple MK/MySQL support of transactions you can do like this (at least it works for me :-). 1) Subclass MySQLObjectStore and override saveChanges: class MyMySQLObjectStore(MySQLObjectStore): def saveChanges(self): self.executeSQL('BEGIN') try: MySQLObjectStore.saveChanges(self) except Exception, e: self.executeSQL('ROLLBACK') raise e else: self.executeSQL('COMMIT') 2) Make sure that your MySQL server supports transactions, i.e install InnoDB. You don't need 4.0 to do this, a recent 3.23 is OK. The prebuilt Windows binaries already have InnoDB installed but on Linux you may have to install it separately. Read more about this on http://www.mysql.com/. 3) Edit GeneratedSQL/Create.sql and add TYPE=InnoDB after every create table: create table MyClass ( myClassId int not null primary key auto_increment, ) TYPE=InnoDB; The last step must be repeated every time you generate your SQL files from the object model :-( But if we ask Chuck kindly he might fix this in the MK generate stuff :-). It would be perfect if one could set an option in Settings.config, like 'MySQLTableType':'InnoDB'. /Stefan _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss