I am writing a script (actually a hack to Ed's code in http://leafe.com/archives/msg/379103) for saving un-related & related bizobjs in single transaction (in web2py) --------code start--------- class DE(): """ class for saving related & unrelated bizobjs in a single transaction """ def __init__(self, paernT, unrelatedT): """ 'parenT' is a list of related tables required in Form First table from the parenT list will be taken to begin transaction 'unrelatedT' is a list of unrelated tables required in Form """ self.paernT = paernT self.unrelatedT= unrelatedT def saveT(self): self.paernT[0].beginTransaction() try: #Here, save method of bizobj class is called with 'startTransaction=False' since already a transaction is started. #If this subset is taken in a separate transaction, it might be committed atomically. #Eventually, if the main transaction rolls back, this atomic change would be already committed to the DB. for i in partnT: self.paernT.save(startTransaction=False) for j in self.unrelatedT: j.save(startTransaction=False) except: self.paernT[0].rollbackTransaction else: self.paernT[0].commitTransaction())--------code end--------- I did not digest the purpose of re-writing "isTransactionManager = self._getTransactionToken()" (in Ed's class) since the same code is there in "beginTransaction" method of "dBizobj.py". Also pl. give me your comments/suggestions on the above given code (it is a work-in-progress). Thanks, Vineet
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html --- _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/[email protected]
