[Zope] Persistence in Python Scripts

Cyril Elkaim cyril.elkaim@free.fr
Thu, 8 Mar 2001 11:54:36 +0100


       Hello,

The following code seems to trigger the Persistance machinery.
Is it true?

-----------------------------
## bounds: context, container, script, _, traverse_subpath
## parameters: background, image

result = None

if background == "":
   return "left:0px; top:0px"

for name, object in container.getParentNode().objectItems():
    if name == background:
       back_width = int(object.getProperty("width"))
       back_height = int(object.getProperty("height"))

    if name == image:
       front_width = int(object.getProperty("width"))
       front_height = int(object.getProperty("height"))

left = (back_width - front_width) / 2
top = (back_height - front_height) /2

result = "left:" + str(left) + "px; top:" + str(top) + "px"

return result
------------------------------

The reason I ask this question is that sometimes I get Conflict Error
when this script is executed. It's the case when it's called many times
in the same document.

Cyril Elkaim