[Zope-Checkins] CVS: Zope/lib/python/OFS - SimpleItemInterfaces.py:1.1.2.1 ObjectManager.py:1.141.6.1 SimpleItem.py:1.91.4.1
Shane Hathaway
shane@digicool.com
Wed, 26 Sep 2001 13:42:38 -0400
Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv16253
Modified Files:
Tag: ComponentArchitecture-branch
ObjectManager.py SimpleItem.py
Added Files:
Tag: ComponentArchitecture-branch
SimpleItemInterfaces.py
Log Message:
- The "add" list now includes entries from the ZopeComponents registry.
- Added __bobo_traverse__ and __browser_default__ methods to ObjectManager
so we can start using presentation components.
- Created SimpleItemInterfaces module.
=== Added File Zope/lib/python/OFS/SimpleItemInterfaces.py ===
import Interface
from ComponentArchitecture.Content import Content
class SimpleItemInterfaces (Content):
"""
"""
=== Zope/lib/python/OFS/ObjectManager.py 1.141 => 1.141.6.1 ===
from webdav.NullResource import NullResource
from webdav.Collection import Collection
-from Acquisition import aq_base
+from Acquisition import aq_base, ExplicitAcquisitionWrapper
from urllib import quote
from cStringIO import StringIO
import marshal
@@ -103,6 +103,10 @@
from AccessControl import getSecurityManager
from zLOG import LOG, ERROR
import sys,string,fnmatch,copy
+from App.ZopeComponents import listAddableTypes, AdderEntry, \
+ convertMetaTypeList
+from ZPublisher.Browser import BrowserPublish
+import ComponentArchitecture
import XMLExportImport
customImporters={
@@ -230,27 +234,29 @@
elif hasattr(self, 'aq_acquire'):
try: pmt=self.aq_acquire('_product_meta_types')
except: pass
+ pmt = list(convertMetaTypeList(pmt))
gmt = []
- for entry in Products.meta_types:
+ for entry in (list(convertMetaTypeList(Products.meta_types))
+ + listAddableTypes(self)):
if interfaces is None:
- if entry.get("visibility", None) == "Global":
+ if entry.isGloballyVisible():
gmt.append(entry)
else:
try:
- eil = entry.get("interfaces", None)
- if eil is not None:
+ eil = entry.getInterfaces()
+ if eil:
for ei in eil:
- for i in interfaces:
+ for i in interfaces:
if ei is i or ei.extends(i):
gmt.append(entry)
- raise BreakoutException # only append 1ce
+ raise BreakoutException # only append once
except BreakoutException:
pass
- return list(self.meta_types)+gmt+list(pmt)
+ return list(convertMetaTypeList(self.meta_types)) + gmt + pmt
def _subobject_permissions(self):
return (Products.__ac_permissions__+
@@ -268,8 +274,9 @@
else:
all=self.all_meta_types
for meta_type in all:
- if meta_type.has_key('permission'):
- if user.has_permission(meta_type['permission'],self):
+ p = meta_type.getPermission()
+ if p is not None:
+ if user.has_permission(p, self):
meta_types.append(meta_type)
else:
meta_types.append(meta_type)
@@ -280,12 +287,16 @@
def _setOb(self, id, object): setattr(self, id, object)
def _delOb(self, id): delattr(self, id)
def _getOb(self, id, default=_marker):
- # FIXME: what we really need to do here is ensure that only
- # sub-items are returned. That could have a measurable hit
- # on performance as things are currently implemented, so for
- # the moment we just make sure not to expose private attrs.
- if id[:1] != '_' and hasattr(aq_base(self), id):
- return getattr(self, id)
+ # FIXME: This is really slow ;-)
+ for info in self._objects:
+ if info['id'] == id:
+ r = getattr(self, id)
+ if not hasattr(r, 'aq_base'):
+ # Part of the contract of _getOb() is to always
+ # return a wrapped object.
+ r = ExplicitAcquisitionWrapper(r, self)
+ return r
+ # Not a subobject.
if default is _marker:
raise AttributeError, id
return default
@@ -697,6 +708,30 @@
if request.maybe_webdav_client and not method in ('GET', 'POST'):
return NullResource(self, key, request).__of__(self)
raise KeyError, key
+
+ def __bobo_traverse__(self, request, name=None):
+ if name and name[:3] == '(p)':
+ return ComponentArchitecture.getPresentation(
+ self, name[3:], BrowserPublish)
+ subob = self._getOb(name, None)
+ if subob is None:
+ # b/w compat. This lets us publish methods of self.
+ try:
+ subob = getattr(self, name)
+ except AttributeError:
+ raise request.response.notFoundError(request['URL'])
+ if not BrowserPublish.isImplementedBy(subob):
+ subob = ComponentArchitecture.getPresentation(
+ subob, '_publish', BrowserPublish, subob) # Lame: use a default
+ return subob
+
+ def __browser_default__(self, request):
+ p = ComponentArchitecture.getPresentation(
+ self, '_publish', BrowserPublish, None)
+ if p is None:
+ return (self, ())
+ else:
+ return p.__browser_default__(request)
def findChilds(obj,dirname=''):
=== Zope/lib/python/OFS/SimpleItem.py 1.91 => 1.91.4.1 ===
from Acquisition import aq_base
import time
+from SimpleItemInterfaces import SimpleItemInterfaces
import marshal
import ZDOM
@@ -117,6 +118,9 @@
App.Undo.UndoSupport,
):
"""A common base class for simple, non-container objects."""
+
+ __implements__ = SimpleItemInterfaces
+
isPrincipiaFolderish=0
isTopLevelPrincipiaApplicationObject=0