[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - configure.zcml:1.31.2.2 field.py:1.6.8.1 service.py:1.12.2.1
Jim Fulton
jim@zope.com
Tue, 18 Mar 2003 07:36:20 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv19240/src/zope/app/browser/services
Modified Files:
Tag: local-utility-branch
configure.zcml field.py service.py
Log Message:
Checking in current code to the branch.
It may be in a state of non-working-ness. We'll fix that later.
We're currently trying to clean up the logic for adding configs.
=== Zope3/src/zope/app/browser/services/configure.zcml 1.31.2.1 => 1.31.2.2 ===
--- Zope3/src/zope/app/browser/services/configure.zcml:1.31.2.1 Thu Mar 13 16:00:15 2003
+++ Zope3/src/zope/app/browser/services/configure.zcml Tue Mar 18 07:35:49 2003
@@ -286,6 +286,14 @@
permission="zope.ManageServices"
/>
+<page
+ for="zope.app.services.field.IComponentPath"
+ name="display"
+ class="zope.app.browser.services.field.ComponentPathDisplayWidget"
+ allowed_interface="zope.app.interfaces.browser.form.IBrowserWidget"
+ permission="zope.ManageServices"
+ />
+
<!-- Adapters -->
<editform
=== Zope3/src/zope/app/browser/services/field.py 1.6 => 1.6.8.1 ===
--- Zope3/src/zope/app/browser/services/field.py:1.6 Fri Feb 21 09:53:34 2003
+++ Zope3/src/zope/app/browser/services/field.py Tue Mar 18 07:35:49 2003
@@ -19,11 +19,12 @@
from zope.app.browser.form.widget import BrowserWidget
from zope.app.interfaces.browser.form import IBrowserWidget
-from zope.component import getServiceManager
+from zope.component import getServiceManager, getView
from zope.app.form.widget import Widget
from zope.publisher.browser import BrowserView
from xml.sax.saxutils import quoteattr
from zope.app.interfaces.form import WidgetInputError
+from zope.app.traversing import traverse, locationAsUnicode
class ComponentPathWidget(BrowserWidget):
@@ -40,7 +41,17 @@
def __call__(self):
selected = self._showData()
field = self.context
- return renderPathSelect(field.context, field.type, self.name, selected)
+ return renderPathSelect(field.context, field.type,
+ self.name, selected)
+
+class ComponentPathDisplayWidget(ComponentPathWidget):
+
+ def __call__(self):
+ path = self._showData()
+ path = locationAsUnicode(path)
+ ob = traverse(self.context.context, path)
+ url = getView(ob, 'absolute_url', self.request)
+ return '<a href="%s">%s</a>' % (url, path)
class ComponentLocationWidget(Widget, BrowserView):
=== Zope3/src/zope/app/browser/services/service.py 1.12 => 1.12.2.1 ===
--- Zope3/src/zope/app/browser/services/service.py:1.12 Thu Mar 13 12:04:57 2003
+++ Zope3/src/zope/app/browser/services/service.py Tue Mar 18 07:35:49 2003
@@ -17,7 +17,7 @@
"""
from zope.app.browser.container.adding import Adding
-from zope.component import getView, getAdapter
+from zope.component import getView, getAdapter, queryView
from zope.proxy.context import ContextWrapper, ContextSuper
from zope.app.interfaces.container import IZopeContainer
from zope.component import getServiceManager
@@ -39,6 +39,19 @@
menu_id = "add_component"
+ def add(self, content):
+ # Override so as to save a reference to the added object
+ self.added_object = ContextSuper(ComponentAdding, self).add(content)
+ return self.added_object
+
+ def nextURL(self):
+ v = queryView(self.added_object, "addConfiguration.html", self.request)
+ if v is not None:
+ url = getPhysicalPathString(self.added_object)
+ return url + "/@@addConfiguration.html"
+
+ return ContextSuper(ComponentAdding, self).nextURL()
+
def action(self, type_name, id):
if type_name == "../AddService":
# Special case
@@ -63,27 +76,18 @@
# As a side effect, self.added_object is set by add() above.
ContextSuper(ComponentAdding, self).action(type_name, id)
-
class ServiceAdding(ComponentAdding):
"""Adding subclass used for adding services."""
menu_id = "add_service"
def add(self, content):
- # Override so as to save a reference to the added object
- self.added_object = ContextSuper(ComponentAdding, self).add(content)
- return self.added_object
-
- def action(self, type_name, id):
- # Call the superclass action() method.
- # As a side effect, self.added_object is set by add() above.
- ContextSuper(ServiceAdding, self).action(type_name, id)
-
- if not ILocalService.isImplementedBy(self.added_object):
- raise TypeError("%s is not a local service" % self.added_object)
+ # Override so as to check the type of the new object.
+ # XXX This wants to be generalized!
+ if not ILocalService.isImplementedBy(content):
+ raise TypeError("%s is not a local service" % content)
- url = getPhysicalPathString(self.added_object)
- self.request.response.redirect(url + "/addConfiguration.html")
+ return ContextSuper(ServiceAdding, self).add(content)
class ConfigurationAdding(Adding):