why does my externalmethod generate a ZODB transaction
Hi, I wrote an external method from which I call a ZSQL-method, this runs fine and returns the correct results, but when I look at the ZODB transactions, I see that for each call of the method a transaction is recorded. Even worse, when I make an error in my method, the folder from which I invoked the method is no longer accesseble. I have to undo the transaction first, that's how I found out that there is a transaction happening. here is the code of the External-method: import string import sys sys.path[0:0]=["/usr/local/Zope-2.1.4/Extensions"] from DocumentTemplate import * def dump(self,EA,**kwa): #return EA,kwa s = "<br>" if hasattr(self,EA): ea = apply(getattr(self,EA),(),kwa) #return ea._names,"<br>",ea._schema ead = ea.__dict__ for r in ead.keys(): s = s + r + "<br>" i=getattr(ea,r) if type(i) == type([]) and len(i) > 0: s = s + str(i) + " <br> " for n in i: s = s + str(n) + " | " s=s+"<br>" elif type(i) == type({}): s = s + str(i) + " <br> " for n in i.items(): s = s + str(n) + " | " s=s+"<br>" return s def workform(self,REQUEST): "Die Masken EinAusgabe" scol = "movie_id" sval = "a%" srel = "like" return dump(self,"Row_search",scol=scol,sval=sval,srel=srel) this dumps the result of the ZSQL-method, I call it from a dtml-method "testForm" like this: <dtml-var standard_html_header> <dtml-var "RForm(REQUEST)"> <--- this calls workform <dtml-var standard_html_footer> when invoking this like .../Movies/testForm I have an entry in the undoable transactions: ...Movies/testForm by super on Jul 4 at 21:21:31 By the way why is the day one day off the machine REDhat 6.2 Zope-2.1.4 has the correct date and shows now: Wed Jul 5 21:49:01 CEST 2000 Mit freundlichen Grüßen Joachim Schmitz AixtraWare, Ing. Büro für Internetanwendungen Hüsgenstr. 33a, D-52457 Aldenhoven Telefon: +49-2464-8851, FAX: +49-2464-905163
Hi, answering to myself, cause nobody else could find the reason in the code I provided, because I didn't include the real culprit. Here is the very much abreviatet version, which also generates a transaction: def workform(self,REQUEST): "Die Masken EinAusgabe" self.form=REQUEST.form <-- this does it return "this generated a transaction" So don't modify the "self" of an external method. Mit freundlichen Grüßen Joachim Schmitz AixtraWare, Ing. Büro für Internetanwendungen Hüsgenstr. 33a, D-52457 Aldenhoven Telefon: +49-2464-8851, FAX: +49-2464-905163
On Thu, Jul 06, 2000 at 09:29:53AM +0200, Joachim Schmitz wrote:
answering to myself, cause nobody else could find the reason in the code I provided, because I didn't include the real culprit. Here is the very much abreviatet version, which also generates a transaction:
def workform(self,REQUEST): "Die Masken EinAusgabe" self.form=REQUEST.form <-- this does it return "this generated a transaction"
So don't modify the "self" of an external method.
self is the object this method is called on. So if this is method 'foo' in Folder 'bar', called with http://www.spamandeggs.com/bar/foo, self is bar. The EM is a method of the container object. Indeed, setting self.form will store REQUEST.form in that object attribute, causing Zope to commit a new version of the object. After all, you made a change to it! -- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ | ZopeStudio: http://www.zope.org/Products/ZopeStudio -----------------------------------------------------
make the folder from which it was invoked inaccessable ? continuing work on my external, I removed all modifications of self, so no transactions or better modifications of the ZODB took place. During the development cycle: editing the external methods, testing it through calling it through the browser, after editing the method the call of .../Movies/testForm resulted in a not found error. also I cannot enter the folder "Movies", if I click on it in the managementscreen, I also get the not found error. There is no transaction to undo, I restarted Zope no luck, I tried to delete the folder and get the error: Error Type: SystemError Error Value: Failed to import class setrecord from module __main__ (Object: manage_delObjects) File /usr/local/Zope-2.1.4/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: manage_delObjects) File /usr/local/Zope-2.1.4/lib/python/OFS/ObjectManager.py, line 395, in manage_delObjects (Object: ElementWithAttributes) File /usr/local/Zope-2.1.4/lib/python/OFS/ObjectManager.py, line 267, in _delObject (Object: ElementWithAttributes) File /usr/local/Zope-2.1.4/lib/python/ZODB/Connection.py, line 396, in setstate SystemError: (see above) The class setrecord is in my external-method. I luckily had packed zodb shortly before that, and it is just a testserver. So I copied the Data.fs.old to Data.fs. Till now I could not reproduce the error. I still have the corrupted Data.fs. But I had that occure before, after making an error in the external method, the calling folder was not accessible anymore. But there I also had modified self, so I had a transaction which I could "undo". Mit freundlichen Grüßen Joachim Schmitz AixtraWare, Ing. Büro für Internetanwendungen Hüsgenstr. 33a, D-52457 Aldenhoven Telefon: +49-2464-8851, FAX: +49-2464-905163
participants (2)
-
Joachim Schmitz -
Martijn Pieters