[Zope-dev] zpatterns: rackmountables must be of-wrapped
Phillip J. Eby
pje@telecommunity.com
Thu, 25 May 2000 08:00:33 -0500
At 01:56 PM 5/25/00 +0400, Jephte CLAIN wrote:
>
>When I don't wrap items like this, I get strange unauthorized errors.
>Only the super user can use the items. All the other users (Managers or
>not) can't.
In normal usage, one only accesses a rack from or in a Specialist.
Specialists wrap the objects in the context of the specialist for you.
I've just checked the code, however, and notice that
Specialist.__bobo_traverse__ does this wrapping, not Specialist.getItem, so
I will fix this in the next release. That way, calling getItem on the
Specialist will ensure you have proper context. Patch follows...
Index: Specialists.py
===================================================================
RCS file: /u/idsuser/REPOSITORY/ZProducts/ZPatterns/Specialists.py,v
retrieving revision 1.7
diff -u -r1.7 Specialists.py
--- Specialists.py 2000/05/18 05:24:49 1.7
+++ Specialists.py 2000/05/25 12:57:35
@@ -1,7 +1,6 @@
from PlugIns import PlugInGroup
from DataManagers import DataManager
from Globals import HTMLFile, default__class_init__
-
_marker = []
@@ -23,7 +22,7 @@
if ob is _marker:
ob = self.getItem(name)
if ob is not None:
- return getattr(ob,'aq_base',ob).__of__(self)
+ return ob
raise 'NotFound'
return ob
@@ -32,7 +31,8 @@
return self.retrieveItem(key) # XXX need DTML check?
for rack in self.rackList:
item = rack.__of__(self).getItem(key)
- if item is not None: return item
+ if item is not None:
+ return getattr(item,'aq_base',item).__of__(self)
def newItem(self, key=None):
"""Create a new item"""