[Zope-CMF] FSPythonScript Problems Fix! :-)
Chris Withers
chrisw@nipltd.com
Sun, 3 Jun 2001 12:05:55 +0100
This is a multi-part message in MIME format.
------=_NextPart_000_074A_01C0EC25.8AA66680
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
> > ...however, when I look at the resulting Zope object, the binding for
> > namespace and the title appear to have been lost :-S
>
>
> Because the mechanism we use for parsing FSPythonScripts is dropping
> the title on the floor (because it isn't part of the "code object" of
> the temporary PythonScript we create). Please report this bug to the
> tracker.
The attached patch makes bindings and titles work for FSPythonScripts.
It also prevents TTW changing of FSPythonScript bindings, which would
violate the 'you can't edit FS-base objects idea.
(sorry, still didn't manage to create a Tracker item for this ;-)
cheers,
Chris
------=_NextPart_000_074A_01C0EC25.8AA66680
Content-Type: application/octet-stream;
name="FSPythonScript.py.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="FSPythonScript.py.patch"
--- FSPythonScript.py.2 Fri Jun 01 23:14:40 2001
+++ FSPythonScript.py Sun Jun 03 11:58:06 2001
@@ -92,7 +92,7 @@
import Globals
from AccessControl import ClassSecurityInfo, getSecurityManager
from Products.PythonScripts.PythonScript import PythonScript
-from Shared.DC.Scripts.Script import Script, defaultBindings
+from Shared.DC.Scripts.Script import Script
=20
from utils import _dtmldir
from CMFCorePermissions import ViewManagementScreens, View, FTPAccess
@@ -119,10 +119,11 @@
security =3D ClassSecurityInfo()
security.declareObjectProtected(View)
security.declareProtected(View, 'index_html',)
+ # Prevent the bindings from being edited TTW
+ =
security.declarePrivate('ZBindings_edit','ZBindingsHTML_editForm','ZBindi=
ngsHTML_editAction')
=20
def __init__(self, id, filepath, fullname=3DNone, =
properties=3DNone):
FSObject.__init__(self, id, filepath, fullname, properties)
- self.ZBindings_edit(defaultBindings)
=20
security.declareProtected(ViewManagementScreens, 'manage_main')
manage_main =3D Globals.DTMLFile('custpy', _dtmldir)
@@ -201,8 +202,10 @@
ps =3D PythonScript(self.id)
ps._body =3D self._body
ps._params =3D self._params
+ ps.title =3D self.title
+ =
ps._setupBindings(self.getBindingAssignments().getAssignedNames())
return ps.read()
- =20
+ =20
def document_src(self, REQUEST=3DNone, RESPONSE=3DNone):
"""Return unprocessed document source."""
=20
@@ -227,7 +230,7 @@
def _write(self, text):
ps =3D PythonScript(self.id)
ps.write(text)
- ps._makeFunction()
+ ps._makeFunction(1)
ps._editedBindings()
self._v_f =3D f =3D ps._v_f
self._body =3D ps._body
@@ -235,6 +238,8 @@
fc =3D f.func_code
self._setFuncSignature(f.func_defaults, fc.co_varnames,
fc.co_argcount)
+ self.title =3D ps.title
+ =
self._setupBindings(ps.getBindingAssignments().getAssignedNames())
=20
Globals.InitializeClass(FSPythonScript)
=20
------=_NextPart_000_074A_01C0EC25.8AA66680--