[Zope-dev] acquisition, traversal, __roles__(, and zpt?)

Gary Poster Gary Poster" <garyposter@earthlink.net
Wed, 6 Feb 2002 15:41:48 -0500


Hey Chris.  Thanks for the response.

From: "Chris McDonough" <chrism@zope.com>
> Maybe silly questions, but:  Do you call InitializeGlobals() on ObjectX's
> class (usually at the end of the module where it's defined)?

Hmm.  No...do you mean Globals.InitializeClass?  I do that.

> Does ObjectX
> actually have a portal_url method defined on it (or inherited)?

if you are asking if I have masked the CMF portal_url, the answer is no.
I'm mucking about with pdb, and the portal_url I'm working with is
definitely the correct CMF object.

I'm encountering some very odd behavior while messing around with the
CMFSite in the pdb that makes me wonder if the CMF skinned object manager
__of__ or __getattr__ is not quite functioning as it should in the context
of returning portal tools from the main CMFSite instance.  Take a gander at
this pdb dialog excerpt and see if it implies something is rotten in the
state of Denmark (I'll move this over to the CMF list if this does seem to
be something I should pursue as a possible error).  Keep an eye out for the
'***' attribute errors, and the odd behavior of some tools having a
__roles__ property and some tools not...  By the way, 'ObjectX' is an
'Alias' object in the below.  'modernsongs' is the name of my CMF instance.

(this is running on a Zope 2.5 with CMF 1.2 on a win 2k laptop.)

[the end of pdb 'where'...]
> C:\Program
Files\ZopeSongs\lib\python\Products\PageTemplates\Expressions.py(32
2)restrictedTraverse()
-> pdb.set_trace()
(Pdb) l
317                 elif (has(get(object, 'aq_base', object), name)
318                     and get(object, name) == o):
319                     container = object
320                 if not validate(object, container, name, o):
321                     import pdb
322  ->                 pdb.set_trace()
323                     raise Unauthorized, name
324             else:
325                 o=get(object, name, M)
326                 if o is not M:
327                     # Check security.
(Pdb) args
self = <Alias instance at 01885340>
path = []
securityManager = <AccessControl.SecurityManager.SecurityManager instance at
01B
3586C>
get = <built-in function getattr>
has = <built-in function hasattr>
N = None
M = []
TupleType = <type 'tuple'>
(Pdb) o
<MembershipTool instance at 01887188>
(Pdb) o.__roles__
*** AttributeError: __roles__
(Pdb) o.aq_chain
[<MembershipTool instance at 01886D58>, <Alias instance at 01885340>,
<CMFSite instance at 017CF128>, <OrderedFolder instance at 017A3128>,
<Application instance at 017A19E8>, <RequestContainer instance at 017D60D8>]
(Pdb) testObj=o.aq_chain[4]
(Pdb) testObj
<Application instance at 017A19E8>
(Pdb) testObj=testObj.modernsongs
(Pdb) testObj
<CMFSite instance at 017CF128>
(Pdb) testObj.__roles__
('Manager', 'Anonymous')
(Pdb) testObj.Members
<PortalFolder instance at 0188C7D0>
(Pdb) testObj.Members.__roles__
('Manager', 'Anonymous')
(Pdb) testObj.portal_url
<URLTool instance at 0188A6C8>
(Pdb) testObj.portal_url.__roles__
*** AttributeError: __roles__
(Pdb) testObj.portal_catalog.__roles__
('Manager', 'Anonymous')
(Pdb) testObj.portal_membership.__roles__
*** AttributeError: __roles__
(Pdb) testObj.portal_actions.__roles__
*** AttributeError: __roles__
(Pdb) testObj.portal_workflow
<WorkflowTool instance at 0188BC48>
(Pdb) testObj.portal_workflow.__roles__
('Manager', 'Anonymous')
(Pdb) testObj.portal_actions.__roles__
*** AttributeError: __roles__


I did various other tests as well of course, but again I'm aiming for as
much brevity here as possible... ;)

Thanks

Gary