Commit 8c0ed877 authored by Jim Fulton's avatar Jim Fulton

Changed to use persistent method wrappers. This is to avoid

certain bootstrapping problems that can occur when a ZClass instance
is used as a ZClass method.
parent be8426cf
...@@ -184,7 +184,7 @@ class ZClassMethodsSheet( ...@@ -184,7 +184,7 @@ class ZClassMethodsSheet(
return id+' ' return id+' '
def _setOb(self, id, object): def _setOb(self, id, object):
self.setClassAttr(strip(id), MW(object)) self.setClassAttr(strip(id), MWp(object))
def _delOb(self, id): def _delOb(self, id):
self.delClassAttr(strip(id)) self.delClassAttr(strip(id))
...@@ -219,7 +219,7 @@ class ZClassMethodsSheet( ...@@ -219,7 +219,7 @@ class ZClassMethodsSheet(
m._permissionMapper=wrapper m._permissionMapper=wrapper
mw=MW(m) mw=MWp(m)
self.setClassAttr(strip(id), mw) self.setClassAttr(strip(id), mw)
r=m r=m
...@@ -262,13 +262,24 @@ class MW(ExtensionClass.Base): ...@@ -262,13 +262,24 @@ class MW(ExtensionClass.Base):
if hasattr(m,'__of__'): return aqwrap(m, wrapper, parent) if hasattr(m,'__of__'): return aqwrap(m, wrapper, parent)
return m return m
class MWp(Globals.Persistent):
def __init__(self, meth): self.__dict__[methodattr]=meth
__setstate__=__init__
def __getstate__(self):
getattr(self, methodattr)
return self.__dict__[methodattr]
def __of__(self, parent):
m=getattr(self, methodattr)
m=self.__dict__[methodattr]
wrapper=getattr(m, '_permissionMapper', None)
if wrapper is None: wrapper=PermissionMapper()
if hasattr(m,'__of__'): return aqwrap(m, wrapper, parent)
return m
def findMethodIds(klass):
r=[]
for k, v in klass.__dict__.items():
if type(v) is W or type(v) is MW: r.append(k)
return r
# Backward compat. Waaaaa # Backward compat. Waaaaa
class W(Globals.Persistent, MW): class W(Globals.Persistent, MW):
...@@ -292,3 +303,10 @@ class W(Globals.Persistent, MW): ...@@ -292,3 +303,10 @@ class W(Globals.Persistent, MW):
if hasattr(m,'__of__'): return aqwrap(m, self, parent) if hasattr(m,'__of__'): return aqwrap(m, self, parent)
return m return m
def findMethodIds(klass, methodTypes=(MWp, MW, W)):
r=[]
for k, v in klass.__dict__.items():
if type(v) in methodTypes: r.append(k)
return r
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment