Skip to content

Commit

Permalink
Made all methods that edit the body go through write(), so that
Browse files Browse the repository at this point in the history
##metdata= lines can be used.  Collected cache invalidations into _makeFunction.
  • Loading branch information
Evan Simpson committed Jan 4, 2001
1 parent 7fd43d8 commit 142bc0b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions PythonScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
Python code.
"""

__version__='$Revision: 1.6 $'[11:-2]
__version__='$Revision: 1.7 $'[11:-2]

import sys, os, traceback, re
from Globals import MessageDialog, HTMLFile, package_home
Expand Down Expand Up @@ -187,18 +187,18 @@ def ZPythonScriptHTML_editAction(self, REQUEST, title, params, body):
manage_tabs_message=message)

def ZPythonScript_setTitle(self, title):
self.title = str(title)
self.ZCacheable_invalidate()
title = str(title)
if self.title != title:
self.title = title
self.ZCacheable_invalidate()

def ZPythonScript_edit(self, params, body):
self._validateProxy()
self.ZCacheable_invalidate()
if type(body) is not type(''):
body = body.read()
if self._params <> params or self._body <> body:
self._params = str(params)
self._body = rstrip(body)
self._makeFunction(1)
self.write(body)

def ZPythonScriptHTML_upload(self, REQUEST, file=''):
"""Replace the body of the script with the text in file."""
Expand Down Expand Up @@ -275,6 +275,7 @@ def _makeFunction(self, allowSideEffect=0):
from Guarded import WriteGuard, ReadGuard
if allowSideEffect:
self._checkCBlock(GuardedBlock)
self.ZCacheable_invalidate()
if getattr(self, '_v_errors', None):
raise "Python Script Error", ('<pre>%s</pre>' %
join(self._v_errors, '\n') )
Expand All @@ -284,7 +285,6 @@ def _makeFunction(self, allowSideEffect=0):
__builtins__=safebin)

def _editedBindings(self):
self.ZCacheable_invalidate()
f = getattr(self, '_v_f', None)
if f is None:
return
Expand Down Expand Up @@ -377,10 +377,10 @@ def PUT(self, REQUEST, RESPONSE):

def write(self, text):
self._validateProxy()
self.ZCacheable_invalidate()
mdata = self._metadata_map()
bindmap = self.getBindingAssignments().getAssignedNames()
bup = 0

st = 0
try:
while 1:
Expand Down Expand Up @@ -419,10 +419,14 @@ def write(self, text):
bindmap[_nice_bind_names[k[5:]]] = v
bup = 1

self._body = rstrip(body)
body = rstrip(body)
if body != self._body:
self._body = body
if bup:
self._setupBindings(bindmap)
self._makeFunction(1)

if self._p_changed:
self._makeFunction(1)
except:
LOG(self.meta_type, ERROR, 'write failed', error=sys.exc_info())
raise
Expand Down

0 comments on commit 142bc0b

Please sign in to comment.