[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services -
field.py:1.14.12.1
Jim Fulton
cvs-admin at zope.org
Thu Nov 20 16:14:29 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv15106/src/zope/app/browser/services
Modified Files:
Tag: adaptergeddon-branch
field.py
Log Message:
Added Backward compatability support.
=== Zope3/src/zope/app/browser/services/field.py 1.14 => 1.14.12.1 ===
--- Zope3/src/zope/app/browser/services/field.py:1.14 Sun Aug 17 02:05:47 2003
+++ Zope3/src/zope/app/browser/services/field.py Thu Nov 20 16:13:55 2003
@@ -16,9 +16,10 @@
$Id$
"""
+from zope.app import zapi
from zope.app.browser.form.widget import BrowserWidget
-from zope.app.traversing import traverse
-from zope.component import getServiceManager, getView
+from zope.app.interfaces.services.registration \
+ import IRegistrationManagerContainer
__metaclass__ = type
@@ -40,15 +41,34 @@
def __call__(self):
path = self._showData()
path = canonicalPath(path)
- ob = traverse(self.context.context, path)
- url = str(getView(ob, 'absolute_url', self.request))
+ ob = zapi.traverse(self.context.context, path)
+ url = str(zapi.getView(ob, 'absolute_url', self.request))
url += "/@@SelectedManagementView.html"
return '<a href="%s">%s</a>' % (url, path)
+def queryComponent(ob, type):
+ """Find the objects of the given type in the enclosing folder
+ """
+ o = ob
+ while 1:
+ if IRegistrationManagerContainer.isImplementedBy(o):
+ break
+ if o is None:
+ raise ValueError(o, "is not in a service manager container")
+ o = o.__parent__
+
+ result = []
+ for name in o:
+ value = o[name]
+ if type.isImplementedBy(value):
+ result.append({'path': zapi.getPath(value),
+ 'component': value,
+ })
+ return result
+
def renderPathSelect(context, type, name, selected, empty_message=''):
- service_manager = getServiceManager(context)
- info = service_manager.queryComponent(type)
+ info = queryComponent(context, type)
result = []
result.append('<select name="%s">' % name)
More information about the Zope3-Checkins
mailing list