[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/Browser - ComponentConfigEdit.pt:1.1.2.1 ComponentConfigItemEdit.pt:1.1.2.1 ComponentConfigSummary.pt:1.1.2.1 ComponentConfigURL.py:1.1.2.1 NameConfigurableView.py:1.1.2.1 ChangeConfigurations.pt:1.2.10.1 configure.zcml:1.3.2.1

Marius Gedminas mgedmin@codeworks.lt
Tue, 10 Dec 2002 14:16:31 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/Browser
In directory cvs.zope.org:/tmp/cvs-serv28246/lib/python/Zope/App/OFS/Services/Browser

Modified Files:
      Tag: named-component-configuration-branch
	ChangeConfigurations.pt configure.zcml 
Added Files:
      Tag: named-component-configuration-branch
	ComponentConfigEdit.pt ComponentConfigItemEdit.pt 
	ComponentConfigSummary.pt ComponentConfigURL.py 
	NameConfigurableView.py 
Log Message:
Refactoring of configuration views:
  - new interfaces INamedComponentConfiguration, INameConfigurable,
    implemented in NamedComponentConfiguration, NameConfigurable, simplify
    the case where configurations are identified by a name (service types,
    connections, caches, queries, etc)
  - common views for INamedComponentConfiguration, INameConfigurable
  - refactored ServiceManager and ConnectionService to take advantage of the
    new infrastructure
  - incidentally wrote several unit tests for configuration classes
  - removed caching from ComponentConnection.getComponent; this exposed a bug
    in LocalEventService tests



=== Added File Zope3/lib/python/Zope/App/OFS/Services/Browser/ComponentConfigEdit.pt ===
<html metal:use-macro="views/standard_macros/page">
  <body>
  <div metal:fill-slot="body">

    <div metal:use-macro="view/generated_form/macros/body">

      <h3 metal:fill-slot="heading">
          <span tal:replace="context/label">Service</span>
          Configuration
      </h3>

      <table metal:fill-slot="extra_info">
        <tr>
          <td tal:content="context/label">Service type</td>
          <td tal:content="context/name">Foo</td>
        </tr>
        <tr>
          <td>Component Path</td>
          <td tal:content="context/componentPath">
            <a href='.'
               tal:attributes="href view/componentURL"
               tal:content="context/componentPath">foo/bar</a>
          </td>
        </tr>
      </table>

    </div>
  </div>
  </body>
</html>


=== Added File Zope3/lib/python/Zope/App/OFS/Services/Browser/ComponentConfigItemEdit.pt ===
<div metal:use-macro="view/generated_form/macros/formbody">

  <h5 metal:fill-slot="heading">
      <span tal:replace="context/name">Foo</span>
      <span tal:replace="context/label">Service</span>
  </h5>

  <table>
  <tr metal:fill-slot="extra_top">
      <td>Component Path</td>
      <td>
       <a href="."
          tal:content="context/componentPath"
          tal:define="service context/getComponent"
          tal:attributes="href service/@@absolute_url"
          >Foo</a>
      </td>
    </tr>
  </table>

</div>


=== Added File Zope3/lib/python/Zope/App/OFS/Services/Browser/ComponentConfigSummary.pt ===
<span tal:replace="context/title" />
<a href='.'
   tal:attributes="href view/componentURL"
   tal:content="context/componentPath">foo/bar</a>


=== Added File Zope3/lib/python/Zope/App/OFS/Services/Browser/ComponentConfigURL.py ===
##############################################################################
#
# Copyright (c) 2002 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.
#
##############################################################################
"""
$Id: ComponentConfigURL.py,v 1.1.2.1 2002/12/10 19:15:59 mgedmin Exp $
"""

from Zope.ComponentArchitecture import getView
from Zope.App.Traversing import traverse

__metaclass__ = type

class ComponentConfigURL:
    """View mixin that provides an absolute componentURL for
    Component configurations
    """

    def componentURL(self):
        ob = traverse(self.context, self.context.componentPath)
        return str(getView(ob, 'absolute_url', self.request))


__doc__ = ComponentConfigURL.__doc__ + __doc__


=== Added File Zope3/lib/python/Zope/App/OFS/Services/Browser/NameConfigurableView.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 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.
#
##############################################################################
"""Generic INameConfigurable view mixin

$Id: NameConfigurableView.py,v 1.1.2.1 2002/12/10 19:15:59 mgedmin Exp $
"""

from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.ComponentArchitecture import getView
from Zope.App.Traversing import traverse

class NameConfigurableView(BrowserView):

    def update(self):

        names = list(self.context.listConfigurationNames())
        names.sort()

        items = []
        for name in names:
            registry = self.context.queryConfigurations(name)
            view = getView(registry, "ChangeConfigurations", self.request)
            view.setPrefix(name)
            view.update()
            cfg = registry.active()
            active = cfg is not None
            if active:
                ob = traverse(cfg, cfg.componentPath)
                url = str(getView(ob, 'absolute_url', self.request))
            else:
                url = None
            items.append(
                {"name": name,
                 "active": active,
                 "inactive": not active,
                 "view": view,
                 "url": url
                 })

        return items



=== Zope3/lib/python/Zope/App/OFS/Services/Browser/ChangeConfigurations.pt 1.2 => 1.2.10.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/Browser/ChangeConfigurations.pt:1.2	Sat Nov 30 13:35:55 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/Browser/ChangeConfigurations.pt	Tue Dec 10 14:15:59 2002
@@ -1,18 +1,18 @@
 <table width="100%">
   <tr tal:define="message view/message" tal:condition="message">
      <td></td>
-     <td colspan="2"><em tal:content="message">xxxx</em></td> 
+     <td colspan="2"><em tal:content="message">xxxx</em></td>
   </tr>
-  <tr tal:repeat="configuration view/configurations">          
+  <tr tal:repeat="configuration view/configurations">
      <td><input type="radio" name="Roles" value="0"
              tal:attributes="
              name view/name;
              value configuration/id;
              checked configuration/active;
-             " 
+             "
              />
      </td>
-     <td><a href="." 
+     <td><a href="."
             tal:attributes="href string:${view/configBase}/${configuration/id}"
             tal:content="configuration/id"
          >foo/bar</a></td>


=== Zope3/lib/python/Zope/App/OFS/Services/Browser/configure.zcml 1.3 => 1.3.2.1 ===
--- Zope3/lib/python/Zope/App/OFS/Services/Browser/configure.zcml:1.3	Mon Dec  9 11:09:19 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/Browser/configure.zcml	Tue Dec 10 14:15:59 2002
@@ -1,24 +1,69 @@
 <zope:zopeConfigure
    xmlns:zope='http://namespaces.zope.org/zope'
    xmlns="http://namespaces.zope.org/browser"
+   xmlns:form="http://namespaces.zope.org/form"
    package="Zope.App.OFS.Services"
    >
 
-<view
-    for=".ConfigurationInterfaces.IConfigurationStatus"
-    name="edit"
-    factory=".Browser.ConfigurationStatusWidget."
-    allowed_interface="Zope.App.Forms.Views.Browser.IBrowserWidget."
-    permission="Zope.ManageServices"
-    />
-
-<view
-    for=".ConfigurationInterfaces.IConfigurationRegistry"
-    name="ChangeConfigurations"
-    template="Browser/ChangeConfigurations.pt"
-    class=".Browser.ChangeConfigurations."
-    allowed_interface="Zope.App.Forms.Browser.IFormCollaborationView."
-    permission="Zope.ManageServices"
-    />
+<!-- IConfigurationStatus -->
+
+  <view
+      for=".ConfigurationInterfaces.IConfigurationStatus"
+      name="edit"
+      factory=".Browser.ConfigurationStatusWidget."
+      allowed_interface="Zope.App.Forms.Views.Browser.IBrowserWidget."
+      permission="Zope.ManageServices"
+      />
+
+<!-- IConfigurationRegistry -->
+
+  <view
+      for=".ConfigurationInterfaces.IConfigurationRegistry"
+      name="ChangeConfigurations"
+      template="Browser/ChangeConfigurations.pt"
+      class=".Browser.ChangeConfigurations."
+      allowed_interface="Zope.App.Forms.Browser.IFormCollaborationView."
+      permission="Zope.ManageServices"
+      />
+
+<!-- IConfiguration subclasses -->
+
+  <defaultView
+      for=".ConfigurationInterfaces.INamedComponentConfiguration."
+      name="index.html" />
+
+  <menuItems
+      menu="zmi_views"
+      for=".ConfigurationInterfaces.INamedComponentConfiguration.">
+    <menuItem title="Edit" action="index.html"/>
+  </menuItems>
+
+  <form:edit
+      for=".ConfigurationInterfaces.INamedComponentConfiguration."
+      name="index.html"
+      schema="Zope.App.OFS.Services.ConfigurationInterfaces.IConfiguration."
+      label="XXX Configuration"
+      permission="Zope.ManageServices"
+      template="Browser/ComponentConfigEdit.pt"
+      />
+
+  <form:edit
+      for=".ConfigurationInterfaces.INamedComponentConfiguration."
+      name="ItemEdit"
+      schema=
+        "Zope.App.OFS.Services.ConfigurationInterfaces.IConfigurationSummary."
+      template="Browser/ComponentConfigItemEdit.pt"
+      label="XXX not used but can't be omitted"
+      class=".Browser.ComponentConfigURL."
+      permission = "Zope.ManageServices"
+      />
+
+  <view
+      for=".ConfigurationInterfaces.IComponentConfiguration"
+      name="ConfigurationSummary"
+      template="Browser/ComponentConfigSummary.pt"
+      class=".Browser.ComponentConfigURL."
+      permission="Zope.ManageServices"
+      />
 
 </zope:zopeConfigure>