[Zope-Checkins] CVS: Zope/lib/python/OFS - ObjectManager.py:1.141.6.3
Shane Hathaway
shane@digicool.com
Fri, 28 Sep 2001 14:06:43 -0400
Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv8233
Modified Files:
Tag: ComponentArchitecture-branch
ObjectManager.py
Log Message:
Moved the "add" list to a different screen, leaving behind a simple button.
This was needed to support entering an ID for factories without a presentation.
=== Zope/lib/python/OFS/ObjectManager.py 1.141.6.2 => 1.141.6.3 ===
-class ObjectManagerAdder (Acquisition.Explicit):
+class ObjectManagerAdder (Acquisition.Implicit):
"""
"""
- id = None
+ # XXX Uses implicit acquisition so manage_page_* can be found.
+ saved_id = None
__implements__ = Adder, BrowserPublish
- def addToContainer(self, ob, id=None):
- if id is None:
- id = self.id
- self.aq_parent._setObject(id, ob)
+ form = DTMLFile('dtml/add', globals())
+
+ def getTypesByProduct(self):
+ mts = self.aq_parent.filtered_meta_types()
+ res = {}
+ for mt in mts:
+ prod = mt.getProduct()
+ lst = res.get(prod, None)
+ if lst is None:
+ res[prod] = lst = []
+ lst.append(mt)
+ res = res.items()
+ res.sort()
+ return res
+
+ def callFactory(self, factory_id, id, REQUEST=None):
+ """
+ """
+ self.saved_id = id
+ entries = self.aq_parent.filtered_meta_types()
+ for e in entries:
+ if e.getId() == factory_id:
+ return e._invoke(self, id, REQUEST)
+ raise 'NotFound', factory_id
+
+ def getContainerURL(self):
+ """
+ """
+ return getURLOf(self.aq_parent)
+
+ def getName():
+ """
+ """
+ return '(p)add' # XXX
+
+ def addToContainer(self, ob):
+ self.aq_parent._setObject(self.saved_id, ob)
def resultAfterAdd(self):
request = Acquisition.aq_get(self, 'REQUEST', None, 1)
- request.response.redirect(getURLOf(self.aq_parent) + '/manage_main')
+ if request is not None:
+ request.response.redirect(
+ getURLOf(self.aq_parent) + '/manage_main')
return ''
-## return self.aq_parent.manage_workspace(request)
def __bobo_traverse__(self, request, name):
if name[:3] == '(p)':
return ComponentArchitecture.getPresentation(
self, name[3:], BrowserPublish)
elif name[:4] == '(id)':
- self.id = name[4:]
+ self.saved_id = name[4:]
return self
+ elif name[:1] == '_':
+ raise 'NotFound', name
+ elif hasattr(aq_base(self), name):
+ return getattr(self, name)
else:
- raise 'NotFound'
+ raise 'NotFound', name
def __browser_default__(self, request):
raise 'NotFound'