[Zope] Python Scripts need to be recompiled ... again.

Evan Simpson evan@4-am.com
Thu, 09 Aug 2001 11:06:24 -0400


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