> To me, aswell. Is this documented somewhere? ;-)

It's not in the Acquisition.stx in the ExtensionClass docs - 
probably they were never updated when it was added. I think 
that aq_chain is most useful as a debugging aid rather than 
something one would use in an application (which is not to 
say that it shouldn't be documented). It would be a good idea 
to add this to the Collector as a documentation issue.

> And can someone explain to us where the differences between
> aq_chain and getPhysicalPath() are? Actually getPhysicalPath()
> seems also to walk up aq_parent. Or am I missing something?

The sequence returned by aq_chain is the actual chain of 
'acquisition contexts', or the 'access path' rather than 
the actual containment path. For example, given the object 


If you say: ob = app.FolderA.FolderB.FolderA.index_html
then the aq_chain will be:

[index_html, FolderA, FolderB, FolderA, app]

This list is created by basically taking the 'aq_parent' of 
each object from 'ob' on up until there are no more aq_parents.

The actual *containment* path is different; in our example 
the containment path would be: 

[index_html, FolderA, app]

To derive the containment path, instead of just walking up 
the aq_parents you have to take the aq_inner (to get the 
innermost wrapping of the object) for each object and then 
take the aq_parent of that. For example (not tested, but 
should work):

def containment_chain(object):
  # return a list similar to aq_chain, but consisting
  # only of the actual containment path.
  result = []
  while hasattr(object, 'aq_inner'):
      innermost_wrapping = object.aq_inner
      true_parent = innermost_wrapping.aq_parent
      object = true_parent
  return result

Hope this helps!

Brian Lloyd        [EMAIL PROTECTED]
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com 

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

Reply via email to