Persistence in Python Scripts
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
From: "Cyril Elkaim" <cyril.elkaim@free.fr>
The following code seems to trigger the Persistance machinery. Is it true? [snip] 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.
This is probably due to a typo in the 2.3.0 release. Check the file PythonScript.py in the PythonScripts Product for the following line: if getattr(self, Python_magic, None) != Python_magic: ...and change it to: if getattr(self, 'Python_magic', None) != Python_magic: The lack of quotes causes this line to fail every time a Script is loaded, resulting in unnecessary recompilation of the Script object, triggering Persistence. It's fixed in the most recent release. Cheers, Evan @ digicool & 4-am
participants (2)
-
Cyril Elkaim -
Evan Simpson