[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - cacheConfiguration.pt:1.1 cache.py:1.5 cache.zcml:1.2

Guido van Rossum guido@python.org
Thu, 24 Apr 2003 17:01:55 -0400


Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv30948/app/browser/services

Modified Files:
	cache.py cache.zcml 
Added Files:
	cacheConfiguration.pt 
Log Message:
Improve cache object configuration.  Still to do: simplify the cache
manager's main view.


=== Added File Zope3/src/zope/app/browser/services/cacheConfiguration.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<body>
  <div metal:fill-slot="body">

    <p>Configurations for this cache:</p>

    <ul>

      <li tal:repeat="use view/uses">

	<a href="."
	   tal:attributes="href use/url"><span tal:replace="use/name" /></a>
	(<span tal:replace="use/status">Active</span>)

      </li>
    </ul>

    <p><a href="addConfiguration.html">Add a configuration for this connection</a>

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


=== Zope3/src/zope/app/browser/services/cache.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/services/cache.py:1.4	Thu Apr 24 16:28:50 2003
+++ Zope3/src/zope/app/browser/services/cache.py	Thu Apr 24 17:01:25 2003
@@ -17,6 +17,29 @@
 """
 
 from zope.app.browser.services.configuration import AddComponentConfiguration
+from zope.app.interfaces.services.configuration import IUseConfiguration
+from zope.component import getAdapter, getServiceManager, getView
+from zope.publisher.browser import BrowserView
+from zope.app.traversing import traverse
+
+class UseConfiguration(BrowserView):
+
+    """View for displaying the configurations for a connection."""
+
+    def uses(self):
+        """Get a sequence of configuration summaries."""
+        component = self.context
+        useconfig = getAdapter(component, IUseConfiguration)
+        result = []
+        for path in useconfig.usages():
+            config = traverse(component, path)
+            url = getView(config, 'absolute_url', self.request)
+            result.append({'name': config.name,
+                           'path': path,
+                           'url': url(),
+                           'status': config.status,
+                           })
+        return result
 
 class AddCacheConfiguration(AddComponentConfiguration):
 


=== Zope3/src/zope/app/browser/services/cache.zcml 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/services/cache.zcml:1.1	Thu Apr 24 16:28:50 2003
+++ Zope3/src/zope/app/browser/services/cache.zcml	Thu Apr 24 17:01:25 2003
@@ -22,6 +22,18 @@
       description="A Persistent Caching Service for TTW development"
       />
 
+  <!-- ZMI tab named "Configurations" for cache objects.
+       Given a cache object this lets you view all configurations
+       available for it. -->
+  <page
+      for="zope.app.interfaces.cache.cache.ICache"
+      name="cacheConfiguration.html"
+      template="cacheConfiguration.pt"
+      class=".cache.UseConfiguration"
+      permission="zope.ManageServices"
+      menu="zmi_views" title="Configurations"
+      />
+
   <!-- When creating a new cache 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