[Zope-Checkins]
CVS: Releases/Zope/lib/python/Products/PythonScripts
- PythonScript.py:1.46.2.9
Evan Simpson
evan at 4-am.com
Fri Feb 13 11:59:37 EST 2004
Update of /cvs-repository/Releases/Zope/lib/python/Products/PythonScripts
In directory cvs.zope.org:/tmp/cvs-serv20148/lib/python/Products/PythonScripts
Modified Files:
Tag: Zope-2_7-branch
PythonScript.py
Log Message:
DeprecationWarnings in Scripts were converted into mysterious exceptions. Scripts now gain a '_filepath' attribute, used at runtime as the '__file__' global value.
=== Releases/Zope/lib/python/Products/PythonScripts/PythonScript.py 1.46.2.8 => 1.46.2.9 ===
--- Releases/Zope/lib/python/Products/PythonScripts/PythonScript.py:1.46.2.8 Tue Jan 27 14:37:33 2004
+++ Releases/Zope/lib/python/Products/PythonScripts/PythonScript.py Fri Feb 13 11:59:05 2004
@@ -22,6 +22,7 @@
import sys, os, traceback, re, marshal, new
from Globals import DTMLFile, MessageDialog, package_home
import AccessControl, OFS, RestrictedPython
+from Acquisition import aq_parent
from OFS.SimpleItem import SimpleItem
from DateTime.DateTime import DateTime
from urllib import quote
@@ -193,7 +194,7 @@
name = name.strip()
if name and name[0] != '*' and re.match('\w',name):
- param_names.append(name.split('=', 1)[0])
+ param_names.append(name.split('=', 1)[0].strip())
return param_names
def manage_historyCompare(self, rev1, rev2, REQUEST,
@@ -270,6 +271,9 @@
def _makeFunction(self, dummy=0): # CMFCore.FSPythonScript uses dummy arg.
self.ZCacheable_invalidate()
self._compile()
+ if not (aq_parent(self) is None or hasattr(self, '_filepath')):
+ # It needs a _filepath, and has an acquisition wrapper.
+ self._filepath = self.get_filepath()
def _editedBindings(self):
if getattr(self, '_v_ft', None) is not None:
@@ -288,7 +292,7 @@
asgns = self.getBindingAssignments()
name_context = asgns.getAssignedName('name_context', None)
if name_context:
- keyset[name_context] = self.aq_parent.getPhysicalPath()
+ keyset[name_context] = aq_parent(self).getPhysicalPath()
name_subpath = asgns.getAssignedName('name_subpath', None)
if name_subpath:
keyset[name_subpath] = self._getTraverseSubpath()
@@ -313,6 +317,7 @@
g.update(bound_names)
g['__traceback_supplement__'] = (
PythonScriptTracebackSupplement, self, -1)
+ g['__file__'] = getattr(self, '_filepath', None) or self.get_filepath()
f = new.function(fcode, g, None, fadefs)
result = f(*args, **kw)
@@ -320,6 +325,14 @@
# Store the result in the cache.
self.ZCacheable_set(result, keywords=keyset)
return result
+
+ def manage_afterAdd(self, item, container):
+ if item is self:
+ self._filepath = self.get_filepath()
+
+ get_filepath=None # Public
+ def get_filepath(self):
+ return self.meta_type + ':' + '/'.join(self.getPhysicalPath())
def manage_haveProxy(self,r): return r in self._proxy_roles
More information about the Zope-Checkins
mailing list