[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/app/component/browser/ Reimplented the UI for registering utilities using the new APIs.

Jim Fulton jim at zope.com
Tue Apr 18 19:56:11 EDT 2006


Log message for revision 67098:
  Reimplented the UI for registering utilities using the new APIs.
  The UI is much simpler now.  We probably need to make it a tad 
  more sophisticated. See registration.txt.
  

Changed:
  U   Zope3/branches/jim-adapter/src/zope/app/component/browser/configure.zcml
  D   Zope3/branches/jim-adapter/src/zope/app/component/browser/editregistration.pt
  D   Zope3/branches/jim-adapter/src/zope/app/component/browser/registered.pt
  U   Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.pt
  U   Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.py
  A   Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.txt
  D   Zope3/branches/jim-adapter/src/zope/app/component/browser/site.py
  D   Zope3/branches/jim-adapter/src/zope/app/component/browser/site_management.pt
  A   Zope3/branches/jim-adapter/src/zope/app/component/browser/siteregistration.pt
  D   Zope3/branches/jim-adapter/src/zope/app/component/browser/tests/
  A   Zope3/branches/jim-adapter/src/zope/app/component/browser/tests.py
  D   Zope3/branches/jim-adapter/src/zope/app/component/browser/tools.txt
  D   Zope3/branches/jim-adapter/src/zope/app/component/browser/utility.py
  D   Zope3/branches/jim-adapter/src/zope/app/component/browser/utilreg_details.pt

-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/component/browser/configure.zcml
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/configure.zcml	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/configure.zcml	2006-04-18 23:56:09 UTC (rev 67098)
@@ -1,115 +1,50 @@
-<zope:configure
-   xmlns:zope="http://namespaces.zope.org/zope"
-   xmlns="http://namespaces.zope.org/browser">
+<configure
+   xmlns="http://namespaces.zope.org/zope"
+   xmlns:browser="http://namespaces.zope.org/browser"
+   >
 
-  <zope:interface
-    interface="zope.app.component.browser.tools.IToolType" />
+  <browser:addMenuItem
+      class=".tests.Sample"
+      permission="zope.ManageSite"
+      title="Sample"
+      />
 
 <!-- Registration Managemenet -->
 
-  <!-- BBB: Gone with 3.3 -->
-  <!--
-  <zope:view
-      for="zope.app.component.interfaces.registration.IComponentPath"
-      type="zope.publisher.interfaces.browser.IBrowserRequest"
-      provides="zope.app.form.interfaces.IInputWidget"
-      factory=".registration.ComponentPathWidget"
-      permission="zope.Public"
-      />
-
-  <zope:view
-      for="zope.app.component.interfaces.registration.IComponentPath"
-      type="zope.publisher.interfaces.browser.IBrowserRequest"
-      provides="zope.app.form.interfaces.IDisplayWidget"
-      factory=".registration.ComponentPathWidget"
-      permission="zope.Public"
-      />
-  -->
-  <!-- BBB: End of backward-compatibility block -->
-
-  <zope:view
-      for="zope.app.component.interfaces.registration.IComponent"
-      type="zope.publisher.interfaces.browser.IBrowserRequest"
-      provides="zope.app.form.interfaces.IInputWidget"
-      factory=".registration.ComponentWidget"
-      permission="zope.Public"
-      />
-
-  <zope:view
-      for="zope.app.component.interfaces.registration.IComponent"
-      type="zope.publisher.interfaces.browser.IBrowserRequest"
-      provides="zope.app.form.interfaces.IDisplayWidget"
-      factory=".registration.ComponentWidget"
-      permission="zope.Public"
-      />
-
-  <page
-      name="index.html"
-      for="zope.app.component.interfaces.registration.IRegistrationManager"
+  <browser:page
+      for="*"
+      name="registration.html"
       menu="zmi_views" title="Registration"
       permission="zope.ManageSite"
-      class=".registration.EditRegistration"
-      template="editregistration.pt" />
-
-  <!-- For now, we'll allow CMs to be added -->
-
-  <view
-      for="zope.app.component.interfaces.registration.IRegistrationManager"
-      name="+"
-      menu="zmi_actions" title="Add"
-      permission="zope.ManageSite"
-      class=".registration.RegistrationAdding"
-      >
-    <page name="index.html"  attribute="index"  />
-    <page name="action.html" attribute="action" />
-  </view>
-
-  <!-- Generic page for objects that keep track of their registrations.
-       Objects that need to override one of these may need to override
-       both.  The "registrations.html" page is only used for objects
-       that have more than one registration. -->
-
-  <page
-      for="zope.app.component.interfaces.registration.IRegisterable"
-      name="registrations.html"
-      template="registered.pt"
-      class=".registration.Registered"
-      permission="zope.ManageSite"
-      />
-
-  <page
-      for="zope.app.component.interfaces.registration.IRegisterable"
-      name="registration.html"
-      template="registration.pt"
       class=".registration.RegistrationView"
-      permission="zope.ManageSite"
-      menu="zmi_views" title="Registration"
       />
 
-  <menuItem
-      menu="zmi_actions"
-      for="zope.app.component.interfaces.registration.IRegisterableContainer"
-      title="Registrations"
-      action="++registrations++/@@SelectedManagementView.html"
+  <browser:page
+      for="*"
+      name="addRegistration.html"
       permission="zope.ManageSite"
+      class=".registration.AddUtilityRegistration" 
       />
 
+  <adapter factory=".registration.UtilityRegistrationDisplay" /> 
+  <adapter factory=".registration.UtilitySiteRegistrationDisplay" /> 
+
 <!-- Site Management Folder -->
 
-  <addMenuItem
+  <browser:addMenuItem
       class="zope.app.component.site.SiteManagementFolder"
       permission="zope.ManageSite"
       title="Site-Management Folder"
       />
 
-  <page
+  <browser:page
       for="zope.app.component.interfaces.ISiteManagementFolder"
       permission="zope.ManageSite"
       class="zope.app.container.browser.contents.JustContents"
       name="index.html" attribute="index"
       />
 
-  <page
+  <browser:page
       name="contents.html"
       for="zope.app.component.interfaces.ISiteManagementFolder"
       menu="zmi_views" title="Contents"
@@ -118,20 +53,20 @@
       attribute="contents"
       />
 
-  <view
+  <browser:view
       name="+"
       menu="zmi_actions" title="Add"
       for="zope.app.component.interfaces.ISiteManagementFolder"
       permission="zope.ManageSite"
       class="zope.app.component.browser.ComponentAdding"
       >
-    <page name="index.html"  attribute="index"  />
-    <page name="action.html" attribute="action" />
-  </view>
+    <browser:page name="index.html"  attribute="index"  />
+    <browser:page name="action.html" attribute="action" />
+  </browser:view>
 
 <!-- Site Manager navigation action -->
 
-  <page
+  <browser:page
       for="zope.app.component.interfaces.IPossibleSite"
       name="addSiteManager.html"
       permission="zope.ManageSite"
@@ -139,16 +74,16 @@
       attribute="addSiteManager"
       />
 
-  <menuItem
+  <browser:menuItem
       menu="zmi_actions" title="Make a site"
       for="zope.app.component.interfaces.IPossibleSite"
       action="addSiteManager.html"
       filter="python:
-         not modules['zope.app.component.interfaces'].ISite.providedBy(context)"
+        not modules['zope.app.component.interfaces'].ISite.providedBy(context)"
       permission="zope.ManageSite"
       />
 
-  <menuItem
+  <browser:menuItem
       menu="zmi_actions"
       title="Manage Site"
       for="zope.app.component.interfaces.ISite"
@@ -158,127 +93,47 @@
 
 <!-- SiteManager -->
 
-  <menuItems
-      menu="zmi_actions"
-      for="zope.app.component.interfaces.ILocalSiteManager">
-
-    <menuItem
-        title="Visit default folder"
-        action="default/@@SelectedManagementView.html"
-        permission="zope.ManageSite"
-        />
-  </menuItems>
-
-  <page
+  <browser:page
       name="contents.html"
       for="zope.app.component.interfaces.ILocalSiteManager"
-      menu="zmi_views" title="Software"
+      menu="zmi_views" title="Contents"
       permission="zope.ManageSite"
       class="zope.app.container.browser.contents.Contents"
       attribute="contents" />
 
-  <view
+  <browser:view
       name="+"
       menu="zmi_actions" title="Add Site Management Folder"
       for="zope.app.component.interfaces.ILocalSiteManager"
       permission="zope.ManageSite"
       class="zope.app.container.browser.adding.Adding"
       >
-    <page name="index.html" attribute="index"/>
-    <page name="action.html" attribute="action"/>
-  </view>
+    <browser:page name="index.html" attribute="index"/>
+    <browser:page name="action.html" attribute="action"/>
+  </browser:view>
 
-  <pages
+  <browser:pages
       for="zope.app.component.interfaces.ILocalSiteManager"
       permission="zope.ManageSite"
       class="zope.app.container.browser.contents.JustContents"
       >
-    <page name="index.html" attribute="index" />
-  </pages>
+    <browser:page name="index.html" attribute="index" />
+  </browser:pages>
 
-  <view
-      name="SiteManagement"
+  <browser:page
       for="zope.app.component.interfaces.ILocalSiteManager"
-      menu="zmi_views" title="Site Management"
-      class=".tools.SiteManagementView"
+      name="registrations.html"
+      menu="zmi_views" title="Registrations"
       permission="zope.ManageSite"
-      >
-    <page name="index.html" template="site_management.pt" />
-  </view>
+      class=".registration.SiteRegistrationView"
+      />
 
-
-<!-- Utility Registration -->
-
-  <!-- When creating a new utility object, you are taken to this
-       form to configure it.  The form lets you choose a name,
-       an interface, a permission, and a registration status
-       (Inactive or Active). -->
-  <addform
-      label="New Utility Registration"
-      for="zope.app.component.interfaces.ILocalUtility"
-      name="addRegistration.html"
-      schema="zope.app.component.interfaces.IUtilityRegistration"
-      class=".registration.AddComponentRegistration"
+  <browser:menuItem
+      menu="zmi_views" title="Registration"
+      for="zope.app.component.interfaces.ILocalSiteManager"
+      action="registration.html"
+      filter="python:False"
       permission="zope.ManageSite"
-      content_factory="zope.app.component.site.UtilityRegistration"
-      arguments="name provided component"
-      fields="name provided component status permission"
-      >
-    <widget
-        field="name"
-        class="zope.app.form.browser.TextWidget"
-        required="False"
-        convert_missing_value="False"
-        />
-  </addform>
-
-  <!-- When editing the registration of an existing utility object,
-       you are taken to this form.  It is similar to the above add
-       form, but doesn't let you change the name, interface or path.
-       (Thus leaving only permission and registration status.) -->
-  <editform
-      menu="zmi_views" title="Edit"
-      label="Edit Utility Registration"
-      name="index.html"
-      schema="zope.app.component.interfaces.IUtilityRegistration"
-      permission="zope.ManageSite"
-      fields="name provided component status permission" />
-
-  <page
-      for="..interfaces.IUtilityRegistration"
-      name="details"
-      template="utilreg_details.pt"
-      class=".site.UtilityRegistrationDetails"
-      permission="zope.Public"
       />
 
-
-<!-- Adapter Registration -->
-
-  <!-- addform
-      label="New Adapter Registration"
-      schema="zope.app.component.interfaces.IAdapterRegistration"
-      name="addRegistration.html"
-      content_factory="zope.app.component.site.AdapterRegistration"
-      arguments="required provided factoryName"
-      keyword_arguments="name permission"
-      permission="zope.ManageServices"
-      fields="required provided name permission factoryName"
-      /-->
-
-  <!-- addMenuItem
-      view="addAdapterRegistration.html"
-      class="zope.app.component.site.AdapterRegistration"
-      permission="zope.ManageSite"
-      title="Adapter Registration"
-      /-->
-
-  <editform
-    schema="..interfaces.IAdapterRegistration"
-    name="index.html"
-    menu="zmi_views"
-    label="Change adapter"
-    permission="zope.ManageSite"
-    />
-
-</zope:configure>
+</configure>

Deleted: Zope3/branches/jim-adapter/src/zope/app/component/browser/editregistration.pt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/editregistration.pt	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/editregistration.pt	2006-04-18 23:56:09 UTC (rev 67098)
@@ -1,57 +0,0 @@
-<html metal:use-macro="context/@@standard_macros/view"
-    i18n:domain="zope">
-<head>
-  <title metal:fill-slot="title" i18n:translate="">
-    Registration Manager
-  </title>
-</head>
-<body>
-<div metal:fill-slot="body">
-
-  <h2 i18n:translate="">Registration Manager</h2>
-
-  <form action="." method="POST"
-        tal:define="message view/update"
-        tal:attributes="action request/URL">
-
-    <p tal:condition="message" tal:content="message" />
-
-    <table>
-      <thead>
-        <tr>
-          <th></th>
-          <th align="left" i18n:translate="">Summary</th>
-        </tr>
-      </thead>
-      <tbody>
-        <tr tal:repeat="reg view/registrationInfo">
-          <td valign="top">
-            <input type="checkbox" name="keys:list" value="1"
-                   tal:attributes="value reg/name" />
-          </td>
-          <td>
-            <a href="." tal:attributes="href reg/name" i18n:translate="">
-              Config item <span tal:content="reg/name" i18n:name="name"/>
-            </a>
-            <span tal:condition="not:reg/active"
-                i18n:translate="">(disabled)</span>
-            <br />
-            <span tal:content="structure reg/details">
-              Registration Details
-            </span>
-          </td>
-        </tr>
-      </tbody>
-    </table>
-
-    <div class="row">
-      <input type="submit" name="refresh_submit" value="Refresh"
-             i18n:attributes="value refresh-button" />
-      <input type="submit" name="remove_submit" value="Remove"
-             i18n:attributes="value remove-button" />
-    </div>
-  </form>
-
-</div>
-</body>
-</html>

Deleted: Zope3/branches/jim-adapter/src/zope/app/component/browser/registered.pt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/registered.pt	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/registered.pt	2006-04-18 23:56:09 UTC (rev 67098)
@@ -1,25 +0,0 @@
-<html metal:use-macro="context/@@standard_macros/view"
-    i18n:domain="zope">
-<body>
-<div metal:fill-slot="body">
-
-  <p i18n:translate="">Registrations for this object:</p>
-
-  <ul>
-    <li tal:repeat="reg view/registrations">
-
-      <a href=""
-         tal:attributes="href reg/url"
-         tal:content="reg/name">Name</a>
-      (<span tal:replace="reg/status">Active</span>)
-      <span tal:replace="structure reg/details" />
-    </li>
-  </ul>
-
-  <p><a href="addRegistration.html" i18n:translate="">
-    Add a registration for this object
-  </a></p>
-
-</div>
-</body>
-</html>

Modified: Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.pt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.pt	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.pt	2006-04-18 23:56:09 UTC (rev 67098)
@@ -2,53 +2,48 @@
     i18n:domain="zope">
 <body>
 <div metal:fill-slot="body">
+<form tal:attributes="action request/URL" 
+      method="POST"
+      >
 
-<form tal:attributes="action request/URL" method="POST"
-      tal:define="ignored view/update">
-
-  <div tal:condition="view/registered">
-    <div tal:define="registration view/registration">
-      <p i18n:translate="">This object is registered as:</p>
-
-      <div class="registrationSummary">
-        <div tal:content="structure registration/details">
-          Details
-        </div>
-        <div class="modificationLink">
-          <a tal:attributes="href registration/url"
-             i18n:translate="">(modify)</a>
-        </div>
-      </div>
-
-      <tal:block condition="view/active">
-        <p i18n:translate="">This object is currently active.</p>
-        <input type="submit" i18n:attributes="value deactivate-button"
-          value="Deactivate" name="deactivate" />
-      </tal:block>
-      <tal:block condition="not:view/active">
-        <p i18n:translate="">This object is currently inactive.</p>
-        <input type="submit" i18n:attributes="value activate-button"
-          value="Activate" name="activate" />
-      </tal:block>
-    </div>
-
-    <hr />
-    <a href="registrations.html" i18n:translate="">
-      Advanced Options
-    </a>
-
+  <div tal:condition="not:view/registrations">
+    <p i18n:translate="">
+      This object isn't yet registered.  Click 
+      <a href="@@addRegistration.html">here</a>
+      to register the object.
+    </p>
   </div>
-
-  <div tal:condition="not:view/registered">
-    <p i18n:translate="">This object is not currently active.</p>
-
+  <div tal:condition="view/registrations">
     <p i18n:translate="">
-      This object won't actually be used unless it is registered to
-      perform a specific function and is activated.
+      This object is registered:
     </p>
-
-    <input type="submit" value="Register" name="activate"
-      i18n:attributes="value register-button" />
+    <table>
+      <tr tal:repeat="registration view/registrations">
+         <td>
+           <input type="checkbox" 
+                  class="noborder" name="ids:list"
+                  tal:attributes="value registration/id;
+                                  id registration/id;
+                                  "
+                  />
+         </td>
+         <td tal:content="structure registration/render">
+           zope.app.fooIFoo utility named bob
+           comment: needed a bob
+         </td>
+      </tr>
+      <tr>
+        <td></td>
+        <td>
+          <input type="submit" value="Unregister" name="deactivate"
+                 i18n:attributes="value unregister-button" />
+        </td>
+      </tr>
+    </table>
+    <p>
+      Click <a href="@@addRegistration.html">here</a>
+      to register the object again.
+    </p>
   </div>
 
 </form>

Modified: Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.py	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.py	2006-04-18 23:56:09 UTC (rev 67098)
@@ -15,264 +15,253 @@
 
 $Id$
 """
+
 import warnings
 
-from zope.security.proxy import removeSecurityProxy
-from zope.publisher.browser import BrowserView
+from zope import interface, component, deprecation, schema
+from zope.formlib import form, page
+import zope.component.interfaces
 
+import zope.publisher.interfaces.browser
+import zope.app.pagetemplate
+import zope.app.form
+from zope.security.proxy import removeSecurityProxy
 from zope.app import zapi
-from zope.app.container.browser.adding import Adding
-from zope.app.container.interfaces import INameChooser
-from zope.app.form.browser.widget import SimpleInputWidget
 from zope.app.i18n import ZopeMessageFactory as _
-from zope.app.component import interfaces
-from zope.app.component.interfaces.registration import ActiveStatus
-from zope.app.component.interfaces.registration import InactiveStatus
 
-class RegistrationView(BrowserView):
-    """View for registerable objects that have at most one registration.
+def _registrations(context, comp):
+    sm = component.getSiteManager(context)
+    for r in sm.registeredUtilities():
+        if r.component == comp or comp is None:
+            yield r
+    for r in sm.registeredAdapters():
+        if r.factory == comp or comp is None:
+            yield r
+    for r in sm.registeredSubscriptionAdapters():
+        if r.factory == comp or comp is None:
+            yield r
+    for r in sm.registeredHandlers():
+        if r.factory == comp or comp is None:
+            yield r
 
-    If the object has more than one registration, this performs a
-    redirection to the 'registrations.html' view.
+class IRegistrationDisplay(interface.Interface):
+    """Display registration information
     """
-    def __init__(self, context, request):
-        super(RegistrationView, self).__init__(context, request)
-        useconfig = interfaces.registration.IRegistered(self.context)
-        self.registrations = useconfig.registrations()
 
-    def update(self):
-        """Make changes based on the form submission."""
-        if len(self.registrations) > 1:
-            self.request.response.redirect("registrations.html")
-            return
-        if "deactivate" in self.request:
-            self.registrations[0].status = InactiveStatus
-        elif "activate" in self.request:
-            if not self.registrations:
-                # create a registration:
-                self.request.response.redirect("addRegistration.html")
-                return
-            self.registrations[0].status = ActiveStatus
+    def id():
+        """Return an identifier suitable for use in mapping
+        """
 
-    def active(self):
-        return self.registrations[0].status == ActiveStatus
+    def render():
+        "Return an HTML view of a registration object"
 
-    def registered(self):
-        return bool(self.registrations)
+    def unregister():
+        "Remove the registration by unregistering the component"
 
-    def registration(self):
-        """Return the first registration.
+class ISiteRegistrationDisplay(IRegistrationDisplay):
+    """Display registration information, including the component registered
+    """
+            
+class RegistrationView(page.Page):
 
-        If there are no registrations, raises an error.
-        """
-        return {'url': zapi.absoluteURL(self.registrations[0], self.request),
-                'details': zapi.queryMultiAdapter(
-                    (self.registrations[0], self.request), name='details')
-                }
+    component.adapts(None, zope.publisher.interfaces.browser.IBrowserRequest)
 
+    render = zope.app.pagetemplate.ViewPageTemplateFile('registration.pt')
 
-class Registered(object):
-    """View for registerable objects with more than one registration."""
-
     def registrations(self):
-        registered = interfaces.registration.IRegistered(self.context)
-        return [
-            {'name': zapi.name(reg),
-             'url': zapi.absoluteURL(reg, self.request),
-             'status': reg.status,
-             'details': zapi.queryMultiAdapter((reg, self.request),
-                                               name='details')}
-            for reg in registered.registrations()]
+        registrations = [
+            component.getMultiAdapter((r, self.request), IRegistrationDisplay)
+            for r in sorted(_registrations(self.context, self.context))
+            ]
+        return registrations
 
+    def update(self):
+        registrations = dict([(r.id(), r) for r in self.registrations()])
+        for id in self.request.form.get('ids', ()):
+            r = registrations.get(id)
+            if r is not None:
+                r.unregister()
 
-#############################################################################
-# BBB: Only for backward compatibility. 12/07/2004
-class ComponentPathWidget(SimpleInputWidget):
-    """Widget for displaying component paths
-
-    The widget doesn't actually allow editing. Rather it gets the
-    value by inspecting its field's context. If the context is an
-    IComponentRegistration, then it just gets its value from the
-    component using the field's name. Otherwise, it uses the path to
-    the context.
-    """
-
-    def __init__(self, *args, **kw):
-        warnings.warn(
-            "Use of `ComponentPathWidget` deprecated, since the "
-            "registration code now uses the component directly instead "
-            "of using the component's path.",
-            DeprecationWarning, stacklevel=2,
-            )
-        super(ComponentPathWidget, self).__init__(*args, **kw)
-
     def __call__(self):
-        """See zope.app.browser.interfaces.form.IBrowserWidget"""
-        # Render as a link to the component
-        field = self.context
-        context = field.context
-        if interfaces.registration.IRegistration.providedBy(context):
-            # It's a registration object. Just get the corresponding attr
-            path = getattr(context, field.__name__)
-            # The path may be relative; then interpret relative to ../..
-            if not path.startswith("/"):
-                context = zapi.traverse(context, "../..")
-            component = zapi.traverse(context, path)
-        else:
-            # It must be a component that is about to be configured.
-            component = context
-            # Always use a relative path (just the component name)
-            path = zapi.name(context)
+        self.update()
+        return self.render()
 
-        url = zapi.absoluteURL(component, self.request)
+class UtilityRegistrationDisplay(object):
+    """Utility Registration Details"""
 
-        return ('<a href="%s/@@SelectedManagementView.html">%s</a>'
-                % (url, path))
+    component.adapts(zope.component.interfaces.IUtilityRegistration,
+                     zope.publisher.interfaces.browser.IBrowserRequest)
+    interface.implements(IRegistrationDisplay)
 
-    def hidden(self):
-        """See zope.app.browser.interfaces.form.IBrowserWidget"""
-        return ''
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
 
-    def hasInput(self):
-        """See zope.app.form.interfaces.IWidget"""
-        return 1
+    def provided(self):
+        provided = self.context.provided
+        return provided.__module__ + '.' + provided.__name__
 
-    def getInputValue(self):
-        """See zope.app.form.interfaces.IWidget"""
-        field = self.context
-        context = field.context
-        if interfaces.registration.IRegistration.providedBy(context):
-            # It's a registration object. Just get the corresponding attr
-            path = getattr(context, field.getName())
-        else:
-            # It must be a component that is about to be configured.
-            # Always return a relative path (just the component name)
-            path = zapi.name(context)
+    def id(self):
+        return 'R' + (("%s %s" % (self.provided(), self.context.name))
+                      .encode('utf8')
+                      .encode('base64')
+                      .replace('+', '_')
+                      .replace('=', '')
+                      .replace('\n', '')
+                      )
 
-        return path
-#############################################################################
+    def _comment(self):
+        comment = self.context.info or ''
+        if comment:
+            comment = '<br />comment: ' + comment
+        return comment
 
+    def render(self):
+        name = self.context.name
+        return "%s utility%s%s" % (
+            self.provided(),
+            name and (' named ' + name) or '',
+            self._comment(),
+            )
 
-class ComponentWidget(SimpleInputWidget):
-    """Widget for displaying/entering component paths that point to components.
+    def unregister(self):
+        self.context.registry.unregisterUtility(
+            self.context.component,
+            self.context.provided,
+            self.context.name,
+            )
+            
+class SiteRegistrationView(RegistrationView):
 
-    The widget doesn't actually allow editing. Rather it gets the
-    value by inspecting its field's context. If the context is an
-    IComponentRegistration, then it just gets its value from the
-    component using the field's name. Otherwise, it uses the path to
-    the context.
-    """
+    render = zope.app.pagetemplate.ViewPageTemplateFile('siteregistration.pt')
 
-    def __call__(self):
-        """See zope.app.browser.interfaces.form.IBrowserWidget"""
-        # Render as a link to the component
-        field = self.context
-        context = field.context
-        if interfaces.registration.IRegistration.providedBy(context):
-            # It's a registration object. Just get the corresponding attr
-            component = getattr(context, field.__name__)
-            path = zapi.getPath(component)
-        else:
-            # It must be a component that is about to be configured.
-            component = context
-            # Always use a relative path (just the component name)
-            path = zapi.name(context)
+    def registrations(self):
+        registrations = [
+            component.getMultiAdapter((r, self.request),
+                                      ISiteRegistrationDisplay)
+            for r in sorted(_registrations(self.context, None))
+            ]
+        return registrations
 
-        url = zapi.absoluteURL(component, self.request)
+class UtilitySiteRegistrationDisplay(UtilityRegistrationDisplay):
+    """Utility Registration Details"""
 
-        return ('<a href="%s/@@SelectedManagementView.html">%s</a>'
-                % (url, path))
+    interface.implementsOnly(ISiteRegistrationDisplay)
 
-    def hidden(self):
-        """See zope.app.browser.interfaces.form.IBrowserWidget"""
-        return ''
+    def render(self):
+        url = component.getMultiAdapter(
+            (self.context.component, self.request), name='absolute_url')
+        try:
+            url = url()
+        except TypeError:
+            url = None
 
-    def hasInput(self):
-        """See zope.app.form.interfaces.IWidget"""
-        return 1
+        cname = getattr(self.context.component, '__name__', '(unknown name)')
+        if cname is None:
+            cname = ''
+        if url:
+            cname = '<a href="%s/@@SelectedManagementView.html">%s</a>' % (
+                url, cname)
+        else:
+            cname = '%s (moved or deleted)' % cname
 
-    def getInputValue(self):
-        """See zope.app.form.interfaces.IWidget"""
-        field = self.context
-        context = field.context
-        if interfaces.registration.IRegistration.providedBy(context):
-            # It's a registration object. Just get the corresponding attr
-            return getattr(context, field.getName())
+        name = self.context.name
+        comment = self.context.info
+        
+        return ('%s<br />%s utility%s%s'
+                % (cname,
+                   self.provided(),
+                   name and (' named ' + name) or '',
+                   self._comment(),
+                   )
+                )
 
-        # It must be a component that is about to be configured.
-        return context
+class AddUtilityRegistration(form.Form):
+    """View for registering utilities
 
+    Normally, the provided interface and name are input.
 
-class AddComponentRegistration(BrowserView):
-    """View for adding component registrations
+    A subclass can provide an empty 'name' attribute if the component should
+    always be registered without a name.
 
-    This class is used to define registration add forms.  It provides
-    the ``add`` and ``nextURL`` methods needed when creating add forms
-    for non-IAdding objects.  We need this here because registration
-    add forms are views of the component being configured.
+    A subclass can provide a 'provided' attribute if a component
+    should always be registered with the same interface.
+    
     """
+    component.adapts(None, zope.publisher.interfaces.browser.IBrowserRequest)
 
-    def add(self, registration):
-        """Add a registration
+    form_fields = form.Fields(
+        schema.Choice(
+           __name__ = 'provided',
+           title=_("Provided interface"),
+           description=_("The interface provided by the utility"),
+           vocabulary="Utility Component Interfaces",
+           required=True,
+           ),
+        schema.TextLine(
+           __name__ = 'name',
+           title=_("Register As"),
+           description=_("The name under which the utility will be known."),
+           required=False,
+           default=u'',
+           missing_value=u''
+           ),
+        schema.Text(
+           __name__ = 'comment',
+           title=_("Comment"),
+           required=False,
+           default=u'',
+           missing_value=u''
+           ),
+        )
 
-        We are going to add the registration to the local
-        registration manager. We don't want to hard code the name of
-        this, so we'll simply scan the containing folder and add the
-        registration to the first registration manager we find.
-        """
-        component = self.context
+    name = provided = None
 
-        # Get the registration manager for this folder
-        rm = component.__parent__.registrationManager
-        rm.addRegistration(registration)
-        return registration
+    prefix = 'field' # in hopes of making old tests pass. :)
 
-    def nextURL(self):
-        return "@@SelectedManagementView.html"
+    def __init__(self, context, request):
+        if self.name is not None:
+            self.form_fields = self.form_fields.omit('name')
+        if self.provided is not None:
+            self.form_fields = self.form_fields.omit('provided')
+        super(AddUtilityRegistration, self).__init__(context, request)
 
-
-class RegistrationAdding(Adding):
-    """Adding subclass for adding registrations."""
-    menu_id = "add_registration"
-
-    def nextURL(self):
-        return zapi.absoluteURL(self.context, self.request)
-
-
-class EditRegistration(BrowserView):
-    """A view on a registration manager, used by registrations.pt."""
-
     def update(self):
-        """Perform actions depending on user input."""
+        # hack to make work with old tests
+        if 'UPDATE_SUBMIT' in self.request.form:
+            warnings.warn(
+                "Old test needs to be updated.",
+                DeprecationWarning)
+            self.request.form['field.actions.register'] = 'Register'
+            self.request.form['field.comment'] = u''
+        super(AddUtilityRegistration, self).update()
 
-        if 'keys' in self.request:
-            k = self.request['keys']
-        else:
-            k = []
+    @property
+    def label(self):
+        return _("Register a $classname",
+                 mapping=dict(classname=self.context.__class__.__name__)
+                 )
 
-        msg = 'You must select at least one item to use this action'
-
-        if 'remove_submit' in self.request:
-            if not k: return msg
-            self.remove_objects(k)
-        elif 'refresh_submit' in self.request:
-            pass # Nothing to do
-
-        return ''
-
-    def remove_objects(self, key_list):
-        """Unregister and remove the directives from the container."""
-        container = self.context
-        for name in key_list:
-            container[name].status = InactiveStatus
-            del container[name]
-
-    def registrationInfo(self):
-        """Render View for each directives."""
-        return [
-            {'name': name,
-             'url': zapi.absoluteURL(reg, self.request),
-             'active': reg.status == ActiveStatus,
-             'details': zapi.queryMultiAdapter((reg, self.request),
-                                               name='details')}
-            for name, reg in self.context.items()]
+    @form.action(_("Register"))
+    def register(self, action, data):
+        sm = component.getSiteManager(self.context)
+        name = self.name
+        if name is None:
+            name = data['name']
+        provided = self.provided
+        if provided is None:
+            provided = data['provided']
+            
+        
+        # We have to remove the security proxy to save the registration
+        sm.registerUtility(
+            removeSecurityProxy(self.context),
+            provided, name,
+            data['comment'] or '')
+        
+        if 'UPDATE_SUBMIT' in self.request.form:
+            # Backward compat until 3.5
+            self.request.response.redirect('@@SelectedManagementView.html')
+            return
+        
+        self.request.response.redirect('@@registration.html')

Added: Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.txt	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.txt	2006-04-18 23:56:09 UTC (rev 67098)
@@ -0,0 +1,253 @@
+======================
+Component registration
+======================
+
+Registration of objects as components is quite simple.  Currently, any
+object can be registered as a utility.  (In the future, registering
+objects as adapter factories probably will be supported, but only if
+those objects implement interfaces.)
+
+To see how this works, we'll create some objects and register
+them. We'll use the Sample class defined in
+zope.app.component.browser.tests to define 3 sample objects: 
+
+    >>> from zope.app.component.browser.tests import Sample
+    >>> folder = getRootFolder()
+    >>> folder['sample1'] = Sample()
+    >>> folder['sample2'] = Sample()
+    >>> folder['sample3'] = Sample()
+    >>> import transaction
+    >>> transaction.commit()
+
+All objects have a "Registration" tab that is accessable to people
+with the zope.ManageSite permission:
+
+    >>> from zope.testbrowser import Browser
+    >>> browser = Browser()
+    >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+    >>> browser.addHeader('Accept-Language', 'test')
+    >>> browser.open('http://localhost/sample1/@@SelectedManagementView.html')
+    >>> browser.getLink('[[zope][Registration]]').click()
+
+When we first visit the registration tab, we see that there are no
+registrations: 
+
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...[[zope][This object isn't yet registered. Click
+    <a href="@@addRegistration.html">here</a>
+    to register the object. (
+    This object isn't yet registered.  Click
+    <a href="@@addRegistration.html">here</a>
+    to register the object.
+    )]]...
+
+To add a registration, we'll click on the "here" link:
+
+    >>> browser.getLink('here').click()
+
+This will being up a form that provides for selection from the
+interfaces the object provides and provides and entries for name to
+provide the object as and a comment:
+
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...[[zope][Provided interface]]...
+    ...[[zope][The interface provided by the utility]]...
+    <option value="...ISample">....ISample</option>
+    <option value="...ISampleBase">...ISampleBase</option>
+    <option value="...IContained">...IContained</option>
+    <option value="...ILocation">...ILocation</option>
+    <option value="...IPersistent">...IPersistent</option>
+    <option value="...Interface">...Interface</option>
+    ...[[zope][Register As]]...
+    ...[[zope][The name under which the utility will be known.]]...
+    ...[[zope][Comment]]...
+
+The most specific interface is selected, which is usually what we
+want.  If we just enter a comment and submit the form:
+
+    >>> browser.getControl('[[zope][Comment]]').value = 'unnamed sample'
+    >>> browser.getControl('[[zope][Register]]').click()
+
+We'll be redirected to the registrations page and the new registration
+will be shown:
+
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...zope.app.component.browser.tests.ISample
+    utility<br />comment: unnamed sample...
+
+We can create multiple registrations by selecting "here" again:
+
+    >>> browser.getLink('here').click()
+    >>> browser.getControl('[[zope][Register As]]').value = 'one'
+    >>> browser.getControl('[[zope][Register]]').click()
+
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...zope.app.component.browser.tests.ISample
+    utility<br />comment: unnamed sample...
+    ...zope.app.component.browser.tests.ISample
+    utility named one...
+
+Each entry has a checkbox for selecting it.  This can be used to
+unregister an object. We'll unregister the utility named "one":
+
+    >>> browser.getControl(name='ids:list').getControl(
+    ... value='Rem9wZS5hcHAuY29tcG9uZW50LmJyb3dzZXIudGVzdHMuSVNhbXBsZSBvbmU'
+    ... ).selected = True
+    >>> browser.getControl('[[zope][unregister-button (Unregister)]]').click()
+    >>> 'utility named one' not in browser.contents
+    True
+
+If there is already an object registered, new registrations will
+simply override the old. We can see this by creating a registration
+for sample2 and then overriding it's registration by registering
+sample3. First, we register sample2:
+
+    >>> browser.open('http://localhost/sample2/registration.html')
+    >>> browser.getLink('here').click()
+    >>> browser.getControl('[[zope][Register As]]').value = 'two'
+    >>> browser.getControl('[[zope][Register]]').click()
+
+We can see all of the registrations for a site by visting the
+site-manager's registrations page:
+
+    >>> browser.open(
+    ...        'http://localhost/++etc++site/@@SelectedManagementView.html')
+    >>> browser.getLink('[[zope][Registrations]]').click()
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...[[zope][Registrations for this site: (
+    Registrations for this site:
+    )]]...
+    ...sample1...zope.app.component.browser.tests.ISample
+    utility<br />comment: unnamed sample...
+    ...sample2...zope.app.component.browser.tests.ISample
+    utility named two...
+
+This shows all of the registrations for the site, including our sample
+registrations. The display includes a link to each component.  Now,
+we'll register sample 3:
+
+    >>> browser.open('http://localhost/sample3/registration.html')
+    >>> browser.getLink('here').click()
+    >>> browser.getControl('[[zope][Register As]]').value = 'two'
+    >>> browser.getControl('[[zope][Register]]').click()
+
+and note that now sample 3, rather than sample 2 is shown in the
+listing of registered components for the site:
+
+    >>> browser.open('http://localhost/++etc++site/@@registrations.html')
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...[[zope][Registrations for this site: (
+    Registrations for this site:
+    )]]...
+    ...sample1...zope.app.component.browser.tests.ISample
+    utility<br />comment: unnamed sample...
+    ...sample3...zope.app.component.browser.tests.ISample
+    utility named two...
+
+    >>> 'sample2' not in browser.contents
+    True
+
+And if we look at sample2's registrations, we'll see it's not registered:
+
+    >>> browser.open('http://localhost/sample2/registration.html')
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...This object isn't yet registered...
+
+Each entry in the site registrations view has a checkbox for selecting
+it.  This can be used to unregister an object. We'll unregister sample3:
+
+    >>> browser.open('http://localhost/++etc++site/@@registrations.html')
+    >>> browser.getControl(name='ids:list').getControl(
+    ... value='Rem9wZS5hcHAuY29tcG9uZW50LmJyb3dzZXIudGVzdHMuSVNhbXBsZSB0d28'
+    ... ).selected = True
+    >>> browser.getControl('[[zope][unregister-button (Unregister)]]').click()
+    >>> 'sample3' not in browser.contents
+    True
+
+    >>> browser.open('http://localhost/sample3/registration.html')
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...This object isn't yet registered...
+
+If a registered object is deleted:
+
+    >>> del folder['sample1']
+    >>> transaction.commit()
+
+It remains registered, and can be unregistered:
+
+    >>> browser.open('http://localhost/++etc++site/@@registrations.html')
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...[[zope][Registrations for this site: (
+    Registrations for this site:
+    )]]...
+    ...(moved or deleted)...zope.app.component.browser.tests.ISample
+    utility<br />comment: unnamed sample...
+
+    >>> browser.getControl(name='ids:list').getControl(
+    ... value="Rem9wZS5hcHAuY29tcG9uZW50LmJyb3dzZXIudGVzdHMuSVNhbXBsZSA"
+    ... ).selected = True
+    >>> browser.getControl('[[zope][unregister-button (Unregister)]]').click()
+
+    >>> 'ISample' not in browser.contents
+    True
+
+The registration view for an object only shows the registrations in
+the immediately enclosing site.  To see this, we register sample2:
+
+    >>> browser.open('http://localhost/sample2/registration.html')
+    >>> browser.getLink('here').click()
+    >>> browser.getControl('[[zope][Register]]').click()
+
+Now we'll create a subsite and move sample2 there:
+
+    >>> browser.open('http://localhost/@@SelectedManagementView.html')
+    >>> browser.getLink('[[zope][Folder]]').click()
+    >>> browser.getControl(name='new_value').value = 'subsite'
+    >>> browser.getControl('Apply').click()
+    >>> browser.getLink('subsite').click()
+    >>> browser.getLink('[[zope][Make a site]').click()
+    >>> browser.open('http://localhost/@@SelectedManagementView.html')
+    >>> browser.getControl(name='ids:list').getControl(value='sample2'
+    ...     ).selected = True
+    >>> browser.getControl('[[zope][container-cut-button (Cut)]]').click()
+    >>> browser.getLink('subsite').click()
+    >>> browser.getControl('[[zope][container-paste-button (Paste)]]').click()
+
+sample2's registration page now indicates that sample2 is
+unregistered:
+
+    >>> browser.open('http://localhost/subsite/registration.html')
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...This object isn't yet registered...
+
+which it is in it's new site.
+
+If we go back to the old site though, we see that sample2 is still
+registered there and that it's link points to it's new location:
+
+    >>> browser.open('http://localhost/++etc++site/@@registrations.html')
+    >>> print browser.contents
+    <!DOCTYPE html ...
+    ...subsite/sample2...zope.app.component.browser.tests.ISample utility...
+
+Of course, this could stand some improvement:
+
+- It would be nice if people were warned when overriding a component
+
+- It would be nice if people were warned when moving a registered
+  component out its site.  Perhaps people should be offered the option of
+  unregistering it, and perhaps registering it in the new location.
+
+- It would be nice if people were warned when deleting a registered
+  component.  Perhaps people should be offered the option of
+  unregistering it.


Property changes on: Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Deleted: Zope3/branches/jim-adapter/src/zope/app/component/browser/site.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/site.py	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/site.py	2006-04-18 23:56:09 UTC (rev 67098)
@@ -1,39 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2005 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Site Management view code
-
-$Id$
-"""
-
-__docformat__ = "reStructuredText"
-
-from zope.app import zapi
-from zope.app.i18n import ZopeMessageFactory as _
-
-
-class UtilityRegistrationDetails(object):
-    """Utility Registration Details"""
-
-    def provided(self):
-        provided = self.context.provided
-        return provided.__module__ + '.' + provided.__name__
-
-    def name(self):
-        return self.context.name or _('<no name>')
-
-    def component(self):
-        url = zapi.getMultiAdapter(
-            (self.context.component, self.request), name='absolute_url')
-        name = zapi.name(self.context.component)
-        return {'url': url, 'name': name}

Deleted: Zope3/branches/jim-adapter/src/zope/app/component/browser/site_management.pt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/site_management.pt	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/site_management.pt	2006-04-18 23:56:09 UTC (rev 67098)
@@ -1,150 +0,0 @@
-<html metal:use-macro="context/@@standard_macros/page"
-    i18n:domain="zope">
-<body>
-<div metal:fill-slot="body">
-
-  <h1 i18n:translate="">
-    <b>Site Management</b>
-  </h1>
-
-  <div class="message"
-       tal:define="message view/update"
-       tal:condition="message"
-       tal:content="message" i18n:translate="">
-    Status Message
-  </div>
-
-  <h2>
-    <b i18n:translate="">Unique Utilities</b>
-  </h2>
-  <div i18n:translate="">
-    Unique utilities can only exist once per site manager and have no name.
-  </div>
-  <br/>
-  <form action="." method="post">
-    <div tal:repeat="tool view/getUniqueTools">
-      <input type="checkbox" name="selected:list" value=""
-             tal:attributes="value tool/name" />
-      <span 
-          tal:content="tool/title"
-          tal:condition="not:tool/exists" i18n:translate="">
-        Authentication
-      </span>
-      <a href="" style="color: green"
-          tal:content="tool/title"
-          tal:condition="tool/exists" i18n:translate="">
-        Authentication
-      </a>
-    </div>
-    <br/>
-    <input type="submit" name="INSTALL-SUBMIT" value="Install"
-     i18n:attributes="value INSTALL-SUBMIT">&nbsp;
-    <input type="submit" name="UNINSTALL-SUBMIT" value="Uninstall"
-     i18n:attributes="value UNINSTALL-SUBMIT">
-  </form>
-
-  <form action="." method="post"
-      tal:repeat="tool view/getTools"
-      tal:attributes="action string:#${tool/name}">
-    <a name="" tal:attributes="name tool/name" />
-    <input type="hidden" name="activeTool" value=""
-           tal:attributes="value tool/name" />
-    <h3>
-      <b tal:content="tool/title" i18n:translate="">Caches</b>
-    </h3>
-    <div tal:content="tool/description" i18n:translate="">
-      Description of the tool
-    </div>
-    <br/>
-    <div class="message"
-         tal:define="message tool/message"
-         tal:condition="message"
-         tal:content="message" i18n:translate="">
-      Status Message
-    </div>
-    <br/>
-    <div tal:define="instances tool/instances">
-      <div tal:repeat="instance instances"
-           tal:condition="instances">
-        <input type="checkbox" name="selected:list" value=""
-               tal:attributes="value instance/name" />
-
-        <span tal:condition="not:instance/rename">
-          <span tal:condition="instance/active" i18n:translate="">
-            <a href="" style="color: green"
-               tal:attributes="href string:${instance/url}/@@SelectedManagementView.html"
-               tal:content="instance/name" i18n:name="name">
-              sql-queries
-            </a>
-            (Active)
-          </span>
-          <span tal:condition="not:instance/active" i18n:translate="">
-            <a href="" style="color: red"
-               tal:attributes="href string:${instance/url}/@@SelectedManagementView.html"
-               tal:content="instance/name" i18n:name="name">
-              sql-queries
-            </a>
-            (Inactive)
-          </span>
-        </span>
-        <span tal:condition="instance/rename">
-          <input type="hidden" name="old_names:list" value=""
-                 tal:attributes="value instance/name" />
-          <input type="text" size="20" name="new_names:list" value=""
-                 tal:condition="not:instance/renameNew"
-                 tal:attributes="value instance/name" />
-          <input type="text" size="20" name="new_names:list" value=""
-                 tal:condition="instance/renameNew"
-                 tal:attributes="value instance/renameNew" />
-        </span>
-
-      </div>
-      <div tal:condition="not:instances"
-         i18n:translate="">
-        <i>No instances of this utility are available yet.</i>
-      </div>
-    </div>
-    <div tal:condition="tool/add">
-      <div tal:define="info view/addingInfo">
-        <input type="text" width="20" name="id" value=""
-          tal:attributes="value tool/addname"
-          />
-        <select name="type_name">
-          <option tal:repeat="entry info"
-                  tal:attributes="value entry/action"
-                  tal:content="entry/title" i18n:translate="">RAM Cache</option>
-        </select>
-        &nbsp;
-        <input type="submit" name="ADD-TOOL-SUBMIT" value="Add"
-          i18n:attributes="value ADD-TOOL-SUBMIT">
-        <input type="submit" name="CANCEL-ADD-TOOL-SUBMIT" value="Cancel"
-          i18n:attributes="value CANCEL-ADD-TOOL-SUBMIT">
-      </div>
-    </div>
-    <br/>
-    <div>
-      <input type="submit" name="ACTIVATE-SUBMIT" value="Activate"
-             i18n:attributes="value ACTIVATE-SUBMIT"
-             tal:condition="not:tool/rename">&nbsp;
-      <input type="submit" name="DEACTIVATE-SUBMIT" value="Deactivate"
-             i18n:attributes="value DEACTIVATE-SUBMIT"
-             tal:condition="not:tool/rename">
-      &nbsp;&nbsp;
-      <input type="submit" name="ADD-SUBMIT" value="Add"
-             i18n:attributes="value ADD-SUBMIT"
-             tal:condition="not:tool/rename">&nbsp;
-      <input type="submit" name="DELETE-SUBMIT" value="Delete"
-             i18n:attributes="value DELETE-SUBMIT"
-             tal:condition="not:tool/rename">&nbsp;
-      <input type="submit" name="RENAME-SUBMIT" value="Rename"
-             i18n:attributes="value RENAME-SUBMIT">&nbsp;
-      <input type="submit" name="RENAME-CANCEL-SUBMIT" value="Cancel"
-             i18n:attributes="value RENAME-CANCEL-SUBMIT"
-             tal:condition="tool/rename">&nbsp;
-    </div>
-    <br/>
-  </form>
-
-</div>
-</body>
-</html>

Copied: Zope3/branches/jim-adapter/src/zope/app/component/browser/siteregistration.pt (from rev 66937, Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.pt)
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/registration.pt	2006-04-13 17:52:04 UTC (rev 66937)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/siteregistration.pt	2006-04-18 23:56:09 UTC (rev 67098)
@@ -0,0 +1,45 @@
+<html metal:use-macro="context/@@standard_macros/view"
+    i18n:domain="zope">
+<body>
+<div metal:fill-slot="body">
+<form tal:attributes="action request/URL" 
+      method="POST"
+      >
+  <div tal:condition="not:view/registrations">
+    <p i18n:translate="">Nothing is registered for this site.</p>
+  </div>
+  <div tal:condition="view/registrations">
+    <p i18n:translate="">
+      Registrations for this site:
+    </p>
+    <table>
+      <tr tal:repeat="registration view/registrations">
+         <td>
+           <input type="checkbox" 
+                  class="noborder" name="ids:list"
+                  tal:attributes="value registration/id;
+                                  id registration/id;
+                                  "
+                  />
+         </td>
+         <td tal:content="structure registration/render">
+           <a href="foo/bar">foo/bar</a><br />
+           zope.app.fooIFoo utility named bob
+           comment: needed a bob
+         </td>
+      </tr>
+      <tr>
+        <td></td>
+        <td>
+          <input type="submit" value="Unregister" name="deactivate"
+                 i18n:attributes="value unregister-button" />
+        </td>
+      </tr>
+    </table>
+  </div>
+
+</form>
+
+</div>
+</body>
+</html>

Added: Zope3/branches/jim-adapter/src/zope/app/component/browser/tests.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/tests.py	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/tests.py	2006-04-18 23:56:09 UTC (rev 67098)
@@ -0,0 +1,40 @@
+##############################################################################
+#
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Registration functional tests
+
+$Id$
+"""
+
+import unittest
+import zope.app.testing.functional
+
+from zope import interface
+
+class ISampleBase(interface.Interface):
+    pass
+
+class ISample(ISampleBase):
+    pass
+
+class Sample:
+    interface.implements(ISample)
+
+
+def test_suite():
+    return zope.app.testing.functional.FunctionalDocFileSuite(
+        'registration.txt')
+        
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
+


Property changes on: Zope3/branches/jim-adapter/src/zope/app/component/browser/tests.py
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Deleted: Zope3/branches/jim-adapter/src/zope/app/component/browser/tools.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/tools.txt	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/tools.txt	2006-04-18 23:56:09 UTC (rev 67098)
@@ -1,156 +0,0 @@
-==============
-The Tools View
-==============
-
-  >>> from zope import interface
-
-XXX There is no documentation in this doctest. :(
-
-First we define a utility to work with :
-
-  >>> from zope.app.content.interfaces import IContentType
-  >>> class IFooUtil(interface.Interface):
-  ...     pass
-  >>> class FooUtil(object):
-  ...     __parent__ = None
-  ...     __name__ = u''
-  ...     interface.implements(IFooUtil, IContentType)
-
-  >>> from zope.app.component.browser import tools
-  >>> from zope import component
-
-We create a tool-configuration utility that provides information for
-the the UI.
-
-  >>> toolConfig = tools.ToolConfiguration(IFooUtil, 'FooUtil')
-  >>> component.provideUtility(toolConfig, name='IFooUtil')
-
-We need a factory to create our new utility :
-
-  >>> from zope.component.interfaces import IFactory
-  >>> from zope.component.factory import Factory
-
-  >>> from zope.app.security import protectclass
-  >>> protectclass.protectName(Factory, '__call__', 'zope.public')
-
-  >>> factory = Factory(FooUtil, 
-  ...                   'Utility for foo',
-  ...                   'This factory creates a foo utility.')
-  >>> component.provideUtility(factory, IFactory, 'IFooUtil')
-
-Let's now invoke our site management :
-
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> request.form['activeTool']='IFooUtil'
-
-  >>> from zope.app import zapi
-  >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
-  >>> view.update()
-  u''
-  >>> request.form['ADD-TOOL-SUBMIT']='submit'
-  >>> request.form['type_name']='IFooUtil'
-  >>> request.form['id']='foo1'
-  >>> view.update()
-  u''
-  >>> util = component.getUtility(IFooUtil, 'foo1')
-  >>> util is not None
-  True
-  >>> current_tools = view.getTools()
-  >>> len(current_tools)
-  1
-  >>> current_tools[0]['instances'][0]['name']
-  'foo1'
-
-Registering with the same name
-------------------------------
-
-  >>> print view.update()
-  The given tool name is already being used.
-
-  >>> request.form['id']='foo2'
-  >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
-  >>> view.update()
-  u''
-  >>> current_tools = view.getTools()
-  >>> current_tools[0]['instances'][0]['name']
-  'foo1'
-  >>> current_tools[0]['instances'][1]['name']
-  'foo2'
-
-Creating a utility without a name
----------------------------------
-
-  >>> request.form['id']=''
-  >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
-  >>> view.update()
-  u''
-  >>> current_tools = view.getTools()
-  >>> current_tools[0]['instances'][0]['name']
-  'foo1'
-  >>> current_tools[0]['instances'][1]['name']
-  'foo2'
-  >>> current_tools[0]['instances'][2]['name']
-  u''
-
-Renaming utilities
-------------------
-
-  >>> request = TestRequest()
-  >>> request.form['activeTool']='IFooUtil'
-  >>> request.form['RENAME-SUBMIT']='submit'
-
-First we rename a single utility :
-
-  >>> request.form['old_names']=['foo1']
-  >>> request.form['new_names']=['JohnDoe']
-  >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
-  >>> view.update()
-  u'Tools successfully renamed.'
-  >>> current_tools = view.getTools()
-  >>> sorted([i['name'] for i in current_tools[0]['instances']])
-  [u'', 'JohnDoe', 'foo2']
-
-  >>> request.form['old_names']=['JohnDoe', 'foo2']
-  >>> request.form['new_names']=['foo1', 'Tres']
-  >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
-  >>> view.update()
-  u'Tools successfully renamed.'
-  >>> current_tools = view.getTools()
-  >>> sorted([i['name'] for i in current_tools[0]['instances']])
-  [u'', 'Tres', 'foo1']
-
-Deleting utilities
-------------------
-
-  >>> request = TestRequest()
-  >>> request.form['activeTool']='IFooUtil'
-  >>> request.form['DELETE-SUBMIT']='submit'
-
-First we try without a selected utility :
-
-  >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
-  >>> view.update()
-  u'No tools selected.'
-
-Now select one utility :
-
-  >>> request.form['selected']=['']
-  >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
-  >>> view.update()
-  u'Tools successfully deleted.'
-  >>> current_tools = view.getTools()
-  >>> current_tools[0]['instances'][0]['name']
-  'foo1'
-  >>> current_tools[0]['instances'][1]['name']
-  'Tres'
-
-Select all the remaining utilities :
-
-  >>> request.form['selected']=['foo1', 'Tres']
-  >>> view = tools.SiteManagementView(zapi.getSiteManager(), request)
-  >>> view.update()
-  u'Tools successfully deleted.'
-  >>> view.getTools()[0]['instances']
-  []
-

Deleted: Zope3/branches/jim-adapter/src/zope/app/component/browser/utility.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/utility.py	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/utility.py	2006-04-18 23:56:09 UTC (rev 67098)
@@ -1,33 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2003 Zope Corporation and Contributors.
-# All Rights Reserved.
-#
-# This software is subject to the provisions of the Zope Public License,
-# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
-# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
-# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
-# FOR A PARTICULAR PURPOSE.
-#
-##############################################################################
-"""Use-Registration view for utilities.
-
-$Id$
-"""
-from zope.app.component.browser.registration import AddComponentRegistration
-from zope.app.component.interfaces.registration import ActiveStatus
-
-class AddRegistration(AddComponentRegistration):
-    """View for adding a utility registration.
-
-    We could just use AddComponentRegistration, except that we need a
-    custom interface widget.
-
-    This is a view on a local utility, configured by an <addform>
-    directive.
-    """
-    def add(self, registration):
-        reg = super(AddRegistration, self).add(registration)
-        reg.status = ActiveStatus
-        return reg

Deleted: Zope3/branches/jim-adapter/src/zope/app/component/browser/utilreg_details.pt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/browser/utilreg_details.pt	2006-04-18 23:56:07 UTC (rev 67097)
+++ Zope3/branches/jim-adapter/src/zope/app/component/browser/utilreg_details.pt	2006-04-18 23:56:09 UTC (rev 67098)
@@ -1,17 +0,0 @@
-<ul style="margin-top: 0; margin-bottom: 0" i18n:domain="zope">
-  <li>
-    <i i18n:translate="">provided:</i>
-    <span tal:content="view/provided">zope.app.interfaces.IMyUtility</span>
-  </li>
-  <li>
-    <i i18n:translate="">name:</i>
-    <span tal:content="view/name" i18n:translate="">myutility</span>
-  </li>
-  <li tal:define="component view/component">
-    <i i18n:translate="">component:</i>
-    <a href=""
-       tal:attributes="href
-         string:${component/url}/@@SelectedManagementView.html"
-       tal:content="component/name" i18n:translate="">myutility</a>
-  </li>
-</ul>



More information about the Zope3-Checkins mailing list