Re: [Zope-dev] zpatterns: rackmountables must be of-wrapped

2000-05-25 Thread Phillip J. Eby

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"""




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




[Zope-dev] zpatterns: rackmountables must be of-wrapped

2000-05-24 Thread Jephte CLAIN

Hello,

I believe items got from a rack have to be wrapped in context of the
rack. I've been bitten by this (and it hurts!). When I try to use items
from DTML, only the superuser can use it, even managers can't access the
objects. When I wrap the items in the context of the rack, everything is
fine.
So: retrieveItem, createItem use vanilla objects
getItem, newItem wrap objects before returning them

regards,
jephte clain
[EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )




Re: [Zope-dev] zpatterns: rackmountables must be of-wrapped

2000-05-24 Thread Phillip J. Eby

At 05:33 PM 5/24/00 +0400, Jephte CLAIN wrote:
Hello,

I believe items got from a rack have to be wrapped in context of the
rack. I've been bitten by this (and it hurts!). When I try to use items
from DTML, only the superuser can use it, even managers can't access the
objects. When I wrap the items in the context of the rack, everything is
fine.
So: retrieveItem, createItem use vanilla objects

retrieveItem and createItem are not intended to be public methods; the only
reason they don't begin with an "_" is that I wanted to make it possible
for them to be implemented as DTMLMethods or PythonMethods.


getItem, newItem wrap objects before returning them

These are the API's you should be using, as they are the ones that tell the
rackmountable what rack it belongs to.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )