[Zope-Checkins] SVN: Zope/branches/philikon-aq/lib/python/OFS/ Use even more proper aq_* method calls

Hanno Schlichting plone at hannosch.info
Sat Jul 28 17:46:19 EDT 2007


Log message for revision 78440:
  Use even more proper aq_* method calls
  

Changed:
  U   Zope/branches/philikon-aq/lib/python/OFS/FindSupport.py
  U   Zope/branches/philikon-aq/lib/python/OFS/PropertySheets.py
  U   Zope/branches/philikon-aq/lib/python/OFS/SimpleItem.py
  U   Zope/branches/philikon-aq/lib/python/OFS/ZDOM.py

-=-
Modified: Zope/branches/philikon-aq/lib/python/OFS/FindSupport.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/OFS/FindSupport.py	2007-07-28 21:24:03 UTC (rev 78439)
+++ Zope/branches/philikon-aq/lib/python/OFS/FindSupport.py	2007-07-28 21:46:18 UTC (rev 78440)
@@ -22,6 +22,7 @@
 from AccessControl.DTML import RestrictedDTML
 from AccessControl.Permission import name_trans
 from AccessControl.Permissions import view_management_screens
+from Acquisition import aq_base
 from DateTime import DateTime
 from DocumentTemplate.DT_Util import Eval
 from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
@@ -92,9 +93,8 @@
                 md=td()
                 obj_expr=(Eval(obj_expr), md, md._push, md._pop)
 
-        base=obj
-        if hasattr(obj, 'aq_base'):
-            base=obj.aq_base
+        base = obj
+        base = aq_base(obj)
 
         if hasattr(base, 'objectItems'):
             try:    items=obj.objectItems()
@@ -118,9 +118,7 @@
             if hasattr(ob, '_p_changed') and (ob._p_changed == None):
                 dflag=1
 
-            if hasattr(ob, 'aq_base'):
-                bs=ob.aq_base
-            else: bs=ob
+            bs = aq_base(ob)
             if (
                 (not obj_ids or absattr(bs.getId()) in obj_ids)
                 and
@@ -200,9 +198,8 @@
                 md=td()
                 obj_expr=(Eval(obj_expr), md, md._push, md._pop)
 
-        base=obj
-        if hasattr(obj, 'aq_base'):
-            base=obj.aq_base
+        base = obj
+        base = aq_base(obj)
 
         if not hasattr(base, 'objectItems'):
             return result
@@ -221,10 +218,7 @@
             if hasattr(ob, '_p_changed') and (ob._p_changed == None):
                 dflag=1
 
-            if hasattr(ob, 'aq_base'):
-                bs=ob.aq_base
-            else: bs=ob
-
+            bs = aq_base(ob)
             if (
                 (not obj_ids or absattr(bs.getId()) in obj_ids)
                 and

Modified: Zope/branches/philikon-aq/lib/python/OFS/PropertySheets.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/OFS/PropertySheets.py	2007-07-28 21:24:03 UTC (rev 78439)
+++ Zope/branches/philikon-aq/lib/python/OFS/PropertySheets.py	2007-07-28 21:46:18 UTC (rev 78440)
@@ -20,13 +20,14 @@
 from ZPublisher.Converters import type_converters
 from Globals import InitializeClass
 from Globals import DTMLFile, MessageDialog
+from Acquisition import aq_base
+from Acquisition import aq_parent
 from Acquisition import Implicit, Explicit
 from App.Common import rfc1123_date, iso8601_date
 from webdav.common import urlbase
 from ExtensionClass import Base
 from Globals import Persistent
 from Traversable import Traversable
-from Acquisition import aq_base
 from AccessControl import ClassSecurityInfo
 from AccessControl.Permissions import access_contents_information
 from AccessControl.Permissions import manage_properties
@@ -71,7 +72,7 @@
             pre=pre+'/'
 
         r=[]
-        for d in self.aq_parent.aq_parent.manage_options:
+        for d in aq_parent(aq_parent(self)).manage_options:
             path=d['action']
             option={'label': d['label'],
                       'action': pre+path,
@@ -92,7 +93,7 @@
             self, script, path)
 
     def meta_type(self):
-        try: return self.aq_parent.aq_parent.meta_type
+        try: return aq_parent(aq_parent(self)).meta_type
         except: return ''
 
 
@@ -489,7 +490,7 @@
         pass
 
     def v_self(self):
-        return self.aq_parent.aq_parent
+        return aq_parent(aq_parent(self))
 
 
 class DefaultProperties(Virtual, PropertySheet, View):
@@ -635,7 +636,7 @@
         return (self.webdav,)
 
     def __propsets__(self):
-        propsets=self.aq_parent.__propsets__
+        propsets = aq_parent(self).__propsets__
         __traceback_info__= propsets, type(propsets)
         return self._get_defaults() + propsets
 
@@ -684,17 +685,17 @@
 
     security.declareProtected(manage_properties, 'addPropertySheet')
     def addPropertySheet(self, propset):
-        propsets=self.aq_parent.__propsets__
-        propsets=propsets+(propset,)
-        self.aq_parent.__propsets__=propsets
+        propsets = aq_parent(self).__propsets__
+        propsets = propsets+(propset,)
+        aq_parent(self).__propsets__ = propsets
 
     security.declareProtected(manage_properties, 'delPropertySheet')
     def delPropertySheet(self, name):
         result=[]
-        for propset in self.aq_parent.__propsets__:
+        for propset in aq_parent(self).__propsets__:
             if propset.getId() != name and  propset.xml_namespace() != name:
                 result.append(propset)
-        self.aq_parent.__propsets__=tuple(result)
+        aq_parent(self).__propsets__=tuple(result)
 
     ## DM: deletion support
     def isDeletable(self,name):
@@ -743,7 +744,7 @@
             pre=pre+'/'
 
         r=[]
-        for d in self.aq_parent.manage_options:
+        for d in aq_parent(self).manage_options:
             r.append({'label': d['label'], 'action': pre+d['action']})
         return r
 

Modified: Zope/branches/philikon-aq/lib/python/OFS/SimpleItem.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/OFS/SimpleItem.py	2007-07-28 21:24:03 UTC (rev 78439)
+++ Zope/branches/philikon-aq/lib/python/OFS/SimpleItem.py	2007-07-28 21:46:18 UTC (rev 78440)
@@ -205,14 +205,16 @@
                 if match is not None:
                     error_message=error_value
 
-            if client is None: client=self
-            if not REQUEST: REQUEST=self.aq_acquire('REQUEST')
+            if client is None:
+                client = self
+            if not REQUEST:
+                REQUEST = aq_acquire(self, 'REQUEST')
 
             try:
                 if hasattr(client, 'standard_error_message'):
                     s=getattr(client, 'standard_error_message')
                 else:
-                    client = client.aq_parent
+                    client = aq_parent(client)
                     s=getattr(client, 'standard_error_message')
                 kwargs = {'error_type': error_type,
                           'error_value': error_value,
@@ -329,7 +331,7 @@
                 raise ValueError('FTP List not supported on acquired objects')
             if not hasattr(ob,'aq_parent'):
                 break
-            ob=ob.aq_parent
+            ob = aq_parent(ob)
 
         stat=marshal.loads(self.manage_FTPstat(REQUEST))
         id = self.getId()

Modified: Zope/branches/philikon-aq/lib/python/OFS/ZDOM.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/OFS/ZDOM.py	2007-07-28 21:24:03 UTC (rev 78439)
+++ Zope/branches/philikon-aq/lib/python/OFS/ZDOM.py	2007-07-28 21:46:18 UTC (rev 78440)
@@ -16,6 +16,8 @@
 All standard Zope objects support DOM to a limited extent.
 """
 import Acquisition
+from Acquisition import aq_base
+from Acquisition import aq_parent
 from Globals import InitializeClass
 from AccessControl import ClassSecurityInfo
 from AccessControl.Permissions import access_contents_information
@@ -149,7 +151,7 @@
         When this is a document this is None"""
         node = self
         if hasattr(node, 'aq_parent'):
-            node = self.aq_parent
+            node = aq_parent(self)
             return node.getOwnerDocument()
         return node
 
@@ -198,7 +200,7 @@
         This is a convenience attribute that allows direct access to
         the child node that is the root element of the document.
         """
-        return self.aq_parent
+        return aq_parent(self)
 
     # Node Methods
     # ------------
@@ -219,17 +221,17 @@
     def getChildNodes(self):
         """Returns a NodeList that contains all children of this node.
         If there are no children, this is a empty NodeList"""
-        return NodeList([self.aq_parent])
+        return NodeList([aq_parent(self)])
 
     def getFirstChild(self):
         """The first child of this node. If there is no such node
         this returns None."""
-        return self.aq_parent
+        return aq_parent(self)
 
     def getLastChild(self):
         """The last child of this node. If there is no such node
         this returns None."""
-        return self.aq_parent
+        return aq_parent(self)
 
     def hasChildNodes(self):
         """Returns true if the node has any children, false
@@ -324,7 +326,7 @@
         """The node immediately preceding this node.  If
         there is no such node, this returns None."""
         if hasattr(self, 'aq_parent'):
-            parent = self.aq_parent
+            parent = aq_parent(self)
             ids=list(parent.objectIds())
             id=self.id
             if type(id) is not type(''): id=id()
@@ -338,7 +340,7 @@
         """The node immediately preceding this node.  If
         there is no such node, this returns None."""
         if hasattr(self, 'aq_parent'):
-            parent = self.aq_parent
+            parent = aq_parent(self)
             ids=list(parent.objectIds())
             id=self.id
             if type(id) is not type(''): id=id()
@@ -432,7 +434,7 @@
 
     def getAttribute(self, name):
         """Retrieves an attribute value by name."""
-        if name=='title' and hasattr(self.aq_base, 'title'):
+        if name=='title' and hasattr(aq_base(self), 'title'):
             return self.title
         return ''
 



More information about the Zope-Checkins mailing list