[Zope-Checkins] CVS: Zope2 - PythonScript.py:1.33.2.2
evan@serenade.digicool.com
evan@serenade.digicool.com
Tue, 10 Jul 2001 12:14:42 -0400
Update of /cvs-repository/Zope2/lib/python/Products/PythonScripts
In directory serenade:/home/evan/Zope/2.4/lib/python/Products/PythonScripts
Modified Files:
Tag: Zope-2_4-branch
PythonScript.py
Log Message:
Make sure Scripts are compiled when they're created. Only add default contents in the constructor, and only if no file is uploaded. Calls to write() always recompile, whether the Script has _p_changed or not.
--- Updated File PythonScript.py in package Zope2 --
--- PythonScript.py 2001/07/02 18:13:41 1.33.2.1
+++ PythonScript.py 2001/07/10 16:14:41 1.33.2.2
@@ -129,8 +129,9 @@
if REQUEST is not None:
file = REQUEST.form.get('file', '')
if type(file) is not type(''): file = file.read()
- if file:
- self._getOb(id).write(file)
+ if not file:
+ file = open(_default_file).read()
+ self._getOb(id).write(file)
try: u = self.DestinationURL()
except: u = REQUEST['URL1']
if submit==" Add and Edit ": u="%s/%s" % (u,quote(id))
@@ -170,7 +171,7 @@
def __init__(self, id):
self.id = id
self.ZBindings_edit(defaultBindings)
- self._body = open(_default_file).read()
+ self._makeFunction()
security = AccessControl.ClassSecurityInfo()
@@ -468,8 +469,7 @@
if bup:
self._setupBindings(bindmap)
- if self._p_changed:
- self._makeFunction()
+ self._makeFunction()
except:
LOG(self.meta_type, ERROR, 'write failed', error=sys.exc_info())
raise