Karl Putland wrote: > --- Geoffrey Talvola <[EMAIL PROTECTED]> wrote: > > The other place you could put a cleanup hook without any mods to > > Webware > > would be in a replacement for _respond(). You could write: > > > > def _respond(self): > > try: > > Page._respond(self) > > except: > > self.rollbackTransaction() > > else: > > self.commitTransaction() > > > > This wouldn't catch errors that happen _during_ the awake() call. > > But maybe > > that's OK. > > Thanks for the idea. For now I guess that's what I'll do. Although > in execpt, it should probably also call call raise to allow the > exception to percolate up to the ErrorHandler. > > ... > except: > self.rollbackTransaction() > raise > else:
Actually, I'm not sure why I suggested replacing _respond(). Replacing respond() (without the underscore) is what I'm using in my application, and it seems like the right place to hook in to me. Also, it takes the transaction as an argument. So the replacement should look like: def respond(self, trans): try: Page.respond(self, trans) except: self.rollbackTransaction() raise else: self.commitTransaction() In fact, you could simply ignore awake() and sleep() entirely and just implement your own before and after methods in respond(), something like this: def respond(self, trans): self.preRespond() try: try: Page.respond(self, trans) except: self.rollbackTransaction() raise else: self.commitTransaction() finally: self.postRespond() Or whatever sequence suits your needs. Provide preRespond() and postRespond() as needed, and just leave awake() and sleep() alone. - Geoff _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss