[Zope-Checkins] CVS: Products/PythonScripts - __init__.py:1.9

Evan Simpson evan@zope.com
Fri, 14 Dec 2001 13:59:28 -0500


Update of /cvs-repository/Products/PythonScripts
In directory cvs.zope.org:/tmp/cvs-serv19703/Products/PythonScripts

Modified Files:
	__init__.py 
Log Message:
Add a function to recompile all Scripts that need it.  It is invoked by visiting /manage_addProducts/PythonScripts/recompile in a browser.


=== Products/PythonScripts/__init__.py 1.8 => 1.9 ===
     context.registerHelpTitle('Script (Python)')
     
+# utility stuff
+
+def recompile(self):
+    '''Recompile all Python Scripts'''
+    base = self.this()
+    scripts = base.ZopeFind(base, obj_metatypes=('Script (Python)',))
+    names = []
+    for name, ob in scripts:
+        if ob._v_change:
+            names.append(name)
+            ob._compile()
+            ob._p_changed = 1
+
+    if names:
+        return 'The following Scripts were recompiled:\n' + '\n'.join(names)
+    return 'No Scripts were found that required recompilation.'
+
+_m = {'recompile': recompile}