Skip to content

Commit

Permalink
Implement getParentNode() in OFS.SimpleItem.Item as it is widely used.
Browse files Browse the repository at this point in the history
  • Loading branch information
lrowe committed Aug 31, 2012
1 parent 7a4c594 commit 77def8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Restructuring
- Removed `mime-types` option from `zope.conf`. You can use the `add_files`
API from `zope.contenttype` instead.

- Removed `OFS.ZDOM`.
- Removed `OFS.ZDOM`. `OFS.SimpleItem.Item` now implements `getParentNode()`.

- Removed the last remaining code to support `SOFTWARE_HOME` and `ZOPE_HOME`.

Expand Down
7 changes: 7 additions & 0 deletions src/OFS/SimpleItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from AccessControl.class_init import InitializeClass
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.Permissions import access_contents_information
from AccessControl.Permissions import view as View
from AccessControl.unauthorized import Unauthorized
from AccessControl.ZopeSecurityPolicy import getRoles
Expand Down Expand Up @@ -369,6 +370,12 @@ def __repr__(self):
res += '>'
return res

security.declareProtected(access_contents_information, 'getParentNode')
def getParentNode(self):
"""The parent of this node. All nodes except Document
DocumentFragment and Attr may have a parent"""
return getattr(self, '__parent__', None)

InitializeClass(Item)


Expand Down

0 comments on commit 77def8a

Please sign in to comment.