[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/CachingService/Views/Browser - AddCacheConfiguration.py:1.1 Caches.pt:1.1 add_cache.pt:1.1 configure.zcml:1.4 Adding.py:NONE

Marius Gedminas mgedmin@codeworks.lt
Thu, 12 Dec 2002 10:28:47 -0500


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

Modified Files:
	configure.zcml 
Added Files:
	AddCacheConfiguration.py Caches.pt add_cache.pt 
Removed Files:
	Adding.py 
Log Message:
Caching service now uses the new configuration infrastructure
Added invalidateAll to Zope.App.Caching.ICache



=== Added File Zope3/lib/python/Zope/App/OFS/Services/CachingService/Views/Browser/AddCacheConfiguration.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.
#
##############################################################################
"""Cache configuration adding view

$Id: AddCacheConfiguration.py,v 1.1 2002/12/12 15:28:16 mgedmin Exp $
"""
__metaclass__ = type

from Zope.ComponentArchitecture import getServiceManager
from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.App.Forms.Utility import setUpWidgets, getWidgetsDataForContent
from Zope.App.OFS.Services.CachingService.ICacheConfiguration \
     import ICacheConfiguration
from Zope.App.OFS.Services.CachingService.CacheConfiguration \
     import CacheConfiguration
from Zope.App.Caching.ICache import ICache

class AddCacheConfiguration(BrowserView):

    def __init__(self, *args):
        super(AddCacheConfiguration, self).__init__(*args)
        setUpWidgets(self, ICacheConfiguration)

    def components(self):
        service = getServiceManager(self.context.context)
        paths = [info['path'] for info in service.queryComponent(type=ICache)]
        paths.sort()
        return paths

    def action(self, cache_name, component_path):
        if not cache_name:
            raise ValueError, 'You must specify a cache name'
        cd = CacheConfiguration(cache_name, component_path)
        cd = self.context.add(cd)
        getWidgetsDataForContent(self, ICacheConfiguration, content=cd)
        self.request.response.redirect(self.context.nextURL())



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

  <h2 metal:fill-slot="heading">Caches configured in this cache service.</h2>

  <p metal:fill-slot="empty_text">No caches have been configured</p>

  <div metal:fill-slot="extra_top">

    <p>For each cache, the cache name is given and all of the
       components registered to provide the cache are shown.  You
       may select the component to provide the cache or disable the
       cache.
    </p>

    <p>Select a cache name or a component name to visit the cache
       or component.
    </p>

  </div>

  <p metal:fill-slot="help_text">To configure a cache, add a database
     adapter component to a <em>package</em> in <a
     href="../../../Packages">Packages</a> or to the <a
     href="../../../Packages/default">default package</a>. After the component
     is added, add a cache configuration that configures the component to
     provide a cache.
  </p>

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


=== Added File Zope3/lib/python/Zope/App/OFS/Services/CachingService/Views/Browser/add_cache.pt ===
<html metal:use-macro="views/standard_macros/page">
<head><title>Add a cache configuration</title></head>
<body>
<div metal:fill-slot="body">

<form action="finish.html" method="post">
  <table>
     <tr>
       <td>Cache Name</td>
       <td><input type="text" name="cache_name" /></td>
     </tr>
     <tr>
       <td>Component</td>
       <td><select name="component_path">
             <option tal:repeat="path view/components"
                     tal:attributes="value path"
                     tal:content="path">path</option>
           </select>
       </td>
     </tr>
     <tr>
       <td>Status</td>
       <td tal:content="structure view/status"><input type="text"></td>
     </tr>
     <tr>
       <td>Title</td>
       <td tal:content="structure view/title"><input type="text"></td>
     </tr>
     <tr>
       <td>Description</td>
       <td tal:content="structure view/description"><textarea></textarea></td>
     </tr>

  </table>
  <input type="submit" />
</form>

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


=== Zope3/lib/python/Zope/App/OFS/Services/CachingService/Views/Browser/configure.zcml 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/App/OFS/Services/CachingService/Views/Browser/configure.zcml:1.3	Thu Oct  3 09:47:30 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/CachingService/Views/Browser/configure.zcml	Thu Dec 12 10:28:16 2002
@@ -3,38 +3,52 @@
    xmlns:browser="http://namespaces.zope.org/browser"
    package="Zope.App.OFS.Services.CachingService">
 
-  <browser:menu id="add_cache"
-      title="Menu for adding new caches." />
+<!-- CachingService -->
 
   <browser:defaultView
-     for=".CachingService.ILocalCachingService"
-     name="contents.html" />
+      for=".CachingService.ILocalCachingService"
+      name="index.html" />
 
-  <browser:view
-     permission="Zope.ManageServices"
-     for=".CachingService.ILocalCachingService"
-     factory="Zope.App.OFS.Container.Views.Browser.Contents.">
+  <browser:menuItems
+      menu="zmi_views"
+      for=".CachingService.ILocalCachingService">
+    <browser:menuItem title="Caches" action="index.html"/>
+  </browser:menuItems>
 
-     <browser:page name="contents.html" attribute="contents" />
-     <browser:page name="removeObjects.html" attribute="removeObjects" />
+  <browser:view
+      for=".CachingService.ILocalCachingService"
+      name="index.html"
+      template="Views/Browser/Caches.pt"
+      class="Zope.App.OFS.Services.Browser.NameConfigurableView."
+      permission="Zope.ManageServices" />
+
+  <browser:menuItem
+      menu="add_component"
+      for="Zope.App.OFS.Container.IAdding."
+      action="CachingService"
+      title="Caching Service"
+      description="A Persistent Caching Service for TTW development"
+      />
 
-  </browser:view>
+<!-- CacheConfiguration -->
 
   <browser:view
-      name="+"
-      for=".CachingService.ILocalCachingService"
-      permission="Zope.ManageContent"
-      factory=".Views.Browser.Adding." >
+      for="Zope.App.OFS.Container.IAdding."
+      name="CacheConfiguration"
+      factory=".Views.Browser.AddCacheConfiguration."
+      permission="Zope.ManageServices">
 
-    <browser:page name="index.html"  attribute="index" />
-    <browser:page name="action.html" attribute="action" />
+    <browser:page name="add.html" template="Views/Browser/add_cache.pt" />
+    <browser:page name="finish.html" attribute="action" />
 
   </browser:view>
 
-  <browser:menuItem menu="add_component" for="Zope.App.OFS.Container.IAdding."
-       action="CachingService"  title="Caching Service"
-       description="A Persistent Caching Service for TTW
-       development"
-       />
+  <browser:menuItem
+      menu="add_configuration"
+      for="Zope.App.OFS.Container.IAdding."
+      action="CacheConfiguration"
+      title="Cache"
+      description="Named Cache"
+      />
 
 </zopeConfigure>

=== Removed File Zope3/lib/python/Zope/App/OFS/Services/CachingService/Views/Browser/Adding.py ===