Back to index

plone3  3.1.7
interfacePatch.py
Go to the documentation of this file.
00001 # Fixes to avoid interface failures, either by broken implementation
00002 # or broken interface declaration.
00003 
00004 # 1. Provide some methods to ObjectManager to silent warnings from
00005 # zope.app.container.interfaces.IContainer
00006 
00007 from Globals import InitializeClass
00008 from AccessControl.Permissions import access_contents_information
00009 from OFS.ObjectManager import ObjectManager
00010 from Products.CMFPlone.utils import _getSecurity
00011 
00012 def __delitem__(self, name):
00013     self.manage_delObjects(ids=[name])
00014 ObjectManager.__delitem__ = __delitem__
00015 
00016 def __contains__(self, name):
00017     return name in self.objectIds()
00018 ObjectManager.__contains__ = __contains__
00019 
00020 def keys(self):
00021     return self.objectIds()
00022 ObjectManager.keys = keys
00023 
00024 def items(self):
00025     return self.objectItems()
00026 ObjectManager.items = items
00027 
00028 def values(self):
00029     return self.objectValues()
00030 ObjectManager.values = values
00031 
00032 def get(self, key, default=None):
00033     return self._getOb(key, default)
00034 ObjectManager.get = get
00035 
00036 def __setitem__(self, key, value):
00037     return self._setObject(key, value)
00038 ObjectManager.__setitem__ = __setitem__
00039 
00040 def __iter__(self):
00041     return iter(self.objectIds())
00042 ObjectManager.__iter__ = __iter__
00043 
00044 # Protect new methods.
00045 security = _getSecurity(ObjectManager)
00046 security.declareProtected(access_contents_information,
00047                           'get', 'keys', 'items', 'values')
00048 InitializeClass(ObjectManager)