[Zope-dev] why does my externalmethod generate a ZODB transaction

Martijn Pieters mj@digicool.com
Thu, 6 Jul 2000 15:53:43 +0200


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
-----------------------------------------------------