Python Scripts need to be recompiled ... again.
2001-08-09T14:38:39 PROBLEM(100) Script (Python) Object "getSmallImages" needs to be recompiled. I know how to go into each script and save it to get it to recompile, but I have dozens and dozens of them that seem to need to be recomipled regularly and at random times. Some of them I haven't changed for a month, yet they "need to be recompiled." Almost worse, the message doesn't tell me where the object is, only the id. I have many objects of the same id in many different places, causing this to be even more of a pain. 1) What causes this need and is there any way to keep them compiled? 2) If there's no way to keep them compiled, is there a way to programmatically check if they need to be compiled and then do so? Thanks! _______________________ Ron Bickers Logic Etc, Inc.
Ron Bickers wrote:
2001-08-09T14:38:39 PROBLEM(100) Script (Python) Object "getSmallImages" needs to be recompiled.
1) What causes this need and is there any way to keep them compiled?
This happens whenever a Script finds itself in a Zope with a different version of Python or RestrictedPython than the one in which it was last compiled. If you upgrade Python or Zope, or export/import a Script from one Zope to another (with a different version of one of these), the Script will complain that it can't use its cached compiled code. The effect of this is slight inefficiency; The Script compiles itself each time it is loaded into memory (usually once per Zope restart). It doesn't automatically save the recompiled code, since this would involve writing itself to the storage as part of some random transaction. Since it notices that it need recompilation during __setstate__, it has no access to its acquisition environment, and doesn't know its full path.
2) If there's no way to keep them compiled, is there a way to programmatically check if they need to be compiled and then do so?
I can probably make a utility script that does this. Cheers, Evan @ 4-am & Zope
-----Original Message----- From: Evan Simpson [mailto:evan@4-am.com]
This happens whenever a Script finds itself in a Zope with a different version of Python or RestrictedPython than the one in which it was last compiled. If you upgrade Python or Zope, or export/import a Script from one Zope to another (with a different version of one of these), the Script will complain that it can't use its cached compiled code.
Thank you for this explanation. Now it doesn't feel so random.
The effect of this is slight inefficiency; The Script compiles itself each time it is loaded into memory (usually once per Zope restart).
So everything works, just not as efficiently as it could. Good.
2) If there's no way to keep them compiled, is there a way to programmatically check if they need to be compiled and then do so?
I can probably make a utility script that does this.
That would be most helpful. Especially if for every upgrade we would need to recompile them all. Thank you! _______________________ Ron Bickers Logic Etc, Inc.
I Got this nice external method from Steve Alexander: I've used the following external method to recompile all my PythonScripts. def recompile_ps(self): metatype='Script (Python)' for name,script in self.ZopeFind(self, search_sub=1, obj_metatypes=[metatype]): print "recompiling",name script.ZPythonScript_edit( script._params, script._body ) return "OK" On Thursday, August 9, 2001, at 10:17 AM, Ron Bickers wrote:
I can probably make a utility script that does this.
That would be most helpful. Especially if for every upgrade we would need to recompile them all.
Thank you! _______________________
Ron Bickers Logic Etc, Inc.
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
) 2001-08-09T14:38:39 PROBLEM(100) Script (Python) Object "getSmallImages" ) needs to be recompiled. ) ) 1) What causes this need and is there any way to keep them compiled? ) ) 2) If there's no way to keep them compiled, is there a way to ) programmatically check if they need to be compiled and then do so? Here is what I ran on a "down"ed Zope: #!/var/www/Zope.12/bin/python # change this to the python that runs zope. import sys # change this to include the Zope/lib/python of INSTANCE_HOME sys.path.insert(0, '/var/www/Zope.12/Zope/lib/python') import Zope def recompile_ps(self): metatype='Script (Python)' for name,script in self.ZopeFind(self, search_sub=1, obj_metatypes=[metatype]): print "recompiling",name try: script.ZPythonScript_edit( script._params, script._body ) except: print "Failed." return "OK" appRoot = Zope.DB.open().root()['Application'] recompile_ps(appRoot) get_transaction().commit() --andy.
participants (6)
-
Andrew Sydelko -
Chris Withers -
Evan Simpson -
Ron Bickers -
Ron Bickers -
Steve Spicklemire