Commit 351434ef authored by Hanno Schlichting's avatar Hanno Schlichting

Use even more proper aq_* method calls

parent 39105ee6
...@@ -22,6 +22,7 @@ from AccessControl import ClassSecurityInfo ...@@ -22,6 +22,7 @@ from AccessControl import ClassSecurityInfo
from AccessControl.DTML import RestrictedDTML from AccessControl.DTML import RestrictedDTML
from AccessControl.Permission import name_trans from AccessControl.Permission import name_trans
from AccessControl.Permissions import view_management_screens from AccessControl.Permissions import view_management_screens
from Acquisition import aq_base
from DateTime import DateTime from DateTime import DateTime
from DocumentTemplate.DT_Util import Eval from DocumentTemplate.DT_Util import Eval
from DocumentTemplate.DT_Util import InstanceDict, TemplateDict from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
...@@ -92,9 +93,8 @@ class FindSupport(ExtensionClass.Base): ...@@ -92,9 +93,8 @@ class FindSupport(ExtensionClass.Base):
md=td() md=td()
obj_expr=(Eval(obj_expr), md, md._push, md._pop) obj_expr=(Eval(obj_expr), md, md._push, md._pop)
base=obj base = obj
if hasattr(obj, 'aq_base'): base = aq_base(obj)
base=obj.aq_base
if hasattr(base, 'objectItems'): if hasattr(base, 'objectItems'):
try: items=obj.objectItems() try: items=obj.objectItems()
...@@ -118,9 +118,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -118,9 +118,7 @@ class FindSupport(ExtensionClass.Base):
if hasattr(ob, '_p_changed') and (ob._p_changed == None): if hasattr(ob, '_p_changed') and (ob._p_changed == None):
dflag=1 dflag=1
if hasattr(ob, 'aq_base'): bs = aq_base(ob)
bs=ob.aq_base
else: bs=ob
if ( if (
(not obj_ids or absattr(bs.getId()) in obj_ids) (not obj_ids or absattr(bs.getId()) in obj_ids)
and and
...@@ -200,9 +198,8 @@ class FindSupport(ExtensionClass.Base): ...@@ -200,9 +198,8 @@ class FindSupport(ExtensionClass.Base):
md=td() md=td()
obj_expr=(Eval(obj_expr), md, md._push, md._pop) obj_expr=(Eval(obj_expr), md, md._push, md._pop)
base=obj base = obj
if hasattr(obj, 'aq_base'): base = aq_base(obj)
base=obj.aq_base
if not hasattr(base, 'objectItems'): if not hasattr(base, 'objectItems'):
return result return result
...@@ -221,10 +218,7 @@ class FindSupport(ExtensionClass.Base): ...@@ -221,10 +218,7 @@ class FindSupport(ExtensionClass.Base):
if hasattr(ob, '_p_changed') and (ob._p_changed == None): if hasattr(ob, '_p_changed') and (ob._p_changed == None):
dflag=1 dflag=1
if hasattr(ob, 'aq_base'): bs = aq_base(ob)
bs=ob.aq_base
else: bs=ob
if ( if (
(not obj_ids or absattr(bs.getId()) in obj_ids) (not obj_ids or absattr(bs.getId()) in obj_ids)
and and
......
...@@ -20,13 +20,14 @@ from webdav.WriteLockInterface import WriteLockInterface ...@@ -20,13 +20,14 @@ from webdav.WriteLockInterface import WriteLockInterface
from ZPublisher.Converters import type_converters from ZPublisher.Converters import type_converters
from Globals import InitializeClass from Globals import InitializeClass
from Globals import DTMLFile, MessageDialog from Globals import DTMLFile, MessageDialog
from Acquisition import aq_base
from Acquisition import aq_parent
from Acquisition import Implicit, Explicit from Acquisition import Implicit, Explicit
from App.Common import rfc1123_date, iso8601_date from App.Common import rfc1123_date, iso8601_date
from webdav.common import urlbase from webdav.common import urlbase
from ExtensionClass import Base from ExtensionClass import Base
from Globals import Persistent from Globals import Persistent
from Traversable import Traversable from Traversable import Traversable
from Acquisition import aq_base
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import access_contents_information from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import manage_properties from AccessControl.Permissions import manage_properties
...@@ -71,7 +72,7 @@ class View(App.Management.Tabs, Base): ...@@ -71,7 +72,7 @@ class View(App.Management.Tabs, Base):
pre=pre+'/' pre=pre+'/'
r=[] r=[]
for d in self.aq_parent.aq_parent.manage_options: for d in aq_parent(aq_parent(self)).manage_options:
path=d['action'] path=d['action']
option={'label': d['label'], option={'label': d['label'],
'action': pre+path, 'action': pre+path,
...@@ -92,7 +93,7 @@ class View(App.Management.Tabs, Base): ...@@ -92,7 +93,7 @@ class View(App.Management.Tabs, Base):
self, script, path) self, script, path)
def meta_type(self): def meta_type(self):
try: return self.aq_parent.aq_parent.meta_type try: return aq_parent(aq_parent(self)).meta_type
except: return '' except: return ''
...@@ -489,7 +490,7 @@ class Virtual: ...@@ -489,7 +490,7 @@ class Virtual:
pass pass
def v_self(self): def v_self(self):
return self.aq_parent.aq_parent return aq_parent(aq_parent(self))
class DefaultProperties(Virtual, PropertySheet, View): class DefaultProperties(Virtual, PropertySheet, View):
...@@ -635,7 +636,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -635,7 +636,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
return (self.webdav,) return (self.webdav,)
def __propsets__(self): def __propsets__(self):
propsets=self.aq_parent.__propsets__ propsets = aq_parent(self).__propsets__
__traceback_info__= propsets, type(propsets) __traceback_info__= propsets, type(propsets)
return self._get_defaults() + propsets return self._get_defaults() + propsets
...@@ -684,17 +685,17 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -684,17 +685,17 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
security.declareProtected(manage_properties, 'addPropertySheet') security.declareProtected(manage_properties, 'addPropertySheet')
def addPropertySheet(self, propset): def addPropertySheet(self, propset):
propsets=self.aq_parent.__propsets__ propsets = aq_parent(self).__propsets__
propsets=propsets+(propset,) propsets = propsets+(propset,)
self.aq_parent.__propsets__=propsets aq_parent(self).__propsets__ = propsets
security.declareProtected(manage_properties, 'delPropertySheet') security.declareProtected(manage_properties, 'delPropertySheet')
def delPropertySheet(self, name): def delPropertySheet(self, name):
result=[] result=[]
for propset in self.aq_parent.__propsets__: for propset in aq_parent(self).__propsets__:
if propset.getId() != name and propset.xml_namespace() != name: if propset.getId() != name and propset.xml_namespace() != name:
result.append(propset) result.append(propset)
self.aq_parent.__propsets__=tuple(result) aq_parent(self).__propsets__=tuple(result)
## DM: deletion support ## DM: deletion support
def isDeletable(self,name): def isDeletable(self,name):
...@@ -743,7 +744,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs): ...@@ -743,7 +744,7 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
pre=pre+'/' pre=pre+'/'
r=[] 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']}) r.append({'label': d['label'], 'action': pre+d['action']})
return r return r
......
...@@ -205,14 +205,16 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -205,14 +205,16 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
if match is not None: if match is not None:
error_message=error_value error_message=error_value
if client is None: client=self if client is None:
if not REQUEST: REQUEST=self.aq_acquire('REQUEST') client = self
if not REQUEST:
REQUEST = aq_acquire(self, 'REQUEST')
try: try:
if hasattr(client, 'standard_error_message'): if hasattr(client, 'standard_error_message'):
s=getattr(client, 'standard_error_message') s=getattr(client, 'standard_error_message')
else: else:
client = client.aq_parent client = aq_parent(client)
s=getattr(client, 'standard_error_message') s=getattr(client, 'standard_error_message')
kwargs = {'error_type': error_type, kwargs = {'error_type': error_type,
'error_value': error_value, 'error_value': error_value,
...@@ -329,7 +331,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable, ...@@ -329,7 +331,7 @@ class Item(Base, Resource, CopySource, App.Management.Tabs, Traversable,
raise ValueError('FTP List not supported on acquired objects') raise ValueError('FTP List not supported on acquired objects')
if not hasattr(ob,'aq_parent'): if not hasattr(ob,'aq_parent'):
break break
ob=ob.aq_parent ob = aq_parent(ob)
stat=marshal.loads(self.manage_FTPstat(REQUEST)) stat=marshal.loads(self.manage_FTPstat(REQUEST))
id = self.getId() id = self.getId()
......
...@@ -16,6 +16,8 @@ DOM implementation in ZOPE : Read-Only methods ...@@ -16,6 +16,8 @@ DOM implementation in ZOPE : Read-Only methods
All standard Zope objects support DOM to a limited extent. All standard Zope objects support DOM to a limited extent.
""" """
import Acquisition import Acquisition
from Acquisition import aq_base
from Acquisition import aq_parent
from Globals import InitializeClass from Globals import InitializeClass
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import access_contents_information from AccessControl.Permissions import access_contents_information
...@@ -149,7 +151,7 @@ class Node: ...@@ -149,7 +151,7 @@ class Node:
When this is a document this is None""" When this is a document this is None"""
node = self node = self
if hasattr(node, 'aq_parent'): if hasattr(node, 'aq_parent'):
node = self.aq_parent node = aq_parent(self)
return node.getOwnerDocument() return node.getOwnerDocument()
return node return node
...@@ -198,7 +200,7 @@ class Document(Acquisition.Explicit, Node): ...@@ -198,7 +200,7 @@ class Document(Acquisition.Explicit, Node):
This is a convenience attribute that allows direct access to This is a convenience attribute that allows direct access to
the child node that is the root element of the document. the child node that is the root element of the document.
""" """
return self.aq_parent return aq_parent(self)
# Node Methods # Node Methods
# ------------ # ------------
...@@ -219,17 +221,17 @@ class Document(Acquisition.Explicit, Node): ...@@ -219,17 +221,17 @@ class Document(Acquisition.Explicit, Node):
def getChildNodes(self): def getChildNodes(self):
"""Returns a NodeList that contains all children of this node. """Returns a NodeList that contains all children of this node.
If there are no children, this is a empty NodeList""" If there are no children, this is a empty NodeList"""
return NodeList([self.aq_parent]) return NodeList([aq_parent(self)])
def getFirstChild(self): def getFirstChild(self):
"""The first child of this node. If there is no such node """The first child of this node. If there is no such node
this returns None.""" this returns None."""
return self.aq_parent return aq_parent(self)
def getLastChild(self): def getLastChild(self):
"""The last child of this node. If there is no such node """The last child of this node. If there is no such node
this returns None.""" this returns None."""
return self.aq_parent return aq_parent(self)
def hasChildNodes(self): def hasChildNodes(self):
"""Returns true if the node has any children, false """Returns true if the node has any children, false
...@@ -324,7 +326,7 @@ class Element(Node): ...@@ -324,7 +326,7 @@ class Element(Node):
"""The node immediately preceding this node. If """The node immediately preceding this node. If
there is no such node, this returns None.""" there is no such node, this returns None."""
if hasattr(self, 'aq_parent'): if hasattr(self, 'aq_parent'):
parent = self.aq_parent parent = aq_parent(self)
ids=list(parent.objectIds()) ids=list(parent.objectIds())
id=self.id id=self.id
if type(id) is not type(''): id=id() if type(id) is not type(''): id=id()
...@@ -338,7 +340,7 @@ class Element(Node): ...@@ -338,7 +340,7 @@ class Element(Node):
"""The node immediately preceding this node. If """The node immediately preceding this node. If
there is no such node, this returns None.""" there is no such node, this returns None."""
if hasattr(self, 'aq_parent'): if hasattr(self, 'aq_parent'):
parent = self.aq_parent parent = aq_parent(self)
ids=list(parent.objectIds()) ids=list(parent.objectIds())
id=self.id id=self.id
if type(id) is not type(''): id=id() if type(id) is not type(''): id=id()
...@@ -432,7 +434,7 @@ class ElementWithTitle(Element): ...@@ -432,7 +434,7 @@ class ElementWithTitle(Element):
def getAttribute(self, name): def getAttribute(self, name):
"""Retrieves an attribute value by 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 self.title
return '' return ''
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment