[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services -
field.py:1.15
Jim Fulton
cvs-admin at zope.org
Fri Nov 21 12:11:33 EST 2003
Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv31668/src/zope/app/browser/services
Modified Files:
field.py
Log Message:
Updated the component path widgets to reflect the fact that we only
every configure components in the same folder (now). This fixed a bug
in the display of templates in page registrations on page folders.
=== Zope3/src/zope/app/browser/services/field.py 1.14 => 1.15 ===
--- 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 Fri Nov 21 12:11:32 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