[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/Browser - NameConfigurable.pt:1.4 NameConfigurableView.py:1.4 ComponentConfigEdit.pt:1.3 NameComponentConfigurableView.py:1.2
Steve Alexander
steve@cat-box.net
Sat, 21 Dec 2002 15:05:47 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/Browser
In directory cvs.zope.org:/tmp/cvs-serv10680/lib/python/Zope/App/OFS/Services/Browser
Modified Files:
ComponentConfigEdit.pt NameComponentConfigurableView.py
Added Files:
NameConfigurable.pt NameConfigurableView.py
Log Message:
refactored NameComponentConfigurableView to derive from a new
NameConfigurableView.
=== Zope3/lib/python/Zope/App/OFS/Services/Browser/NameConfigurable.pt 1.3 => 1.4 ===
--- /dev/null Sat Dec 21 15:05:47 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/Browser/NameConfigurable.pt Sat Dec 21 15:05:46 2002
@@ -0,0 +1,60 @@
+<html metal:use-macro="views/standard_macros/page">
+<body metal:fill-slot="body">
+<div metal:define-macro="body">
+<div tal:define="registries view/update">
+
+ <h2 metal:define-slot="heading">Fruits configured in this fruits manager.</h2>
+
+ <div tal:condition="not:registries">
+ <p metal:define-slot="empty_text">No fruits have been configured</p>
+ </div>
+
+ <div tal:condition="registries">
+
+ <div metal:define-slot="extra_top">
+
+ <p>For each fruit, the fruit name is given and all of the
+ registrations are shown. You may select the
+ registration to provide the fruit or disable the fruit.
+ </p>
+
+ </div>
+
+ <form action="." method="post" tal:attributes="action request/URL">
+
+ <table width="100%">
+
+ <tr tal:repeat="registry registries">
+ <td valign="top" align="right">
+ <span
+ tal:content="registry/name"
+ tal:condition="registry/active"
+ >Orange</span>
+ <span tal:replace="registry/name"
+ tal:condition="registry/inactive" />
+ </td>
+ <td tal:content="structure registry/view">
+ </td>
+ </tr>
+
+ </table>
+
+ <input type=submit name="submit_update" value="Update"><br>
+
+ </form>
+
+ <div metal:define-slot="extra_bottom" />
+
+ </div>
+
+ <p metal:define-slot="help_text">To configure a fruit, add a fruit component
+ to a <em>package</em> in <a href="Packages">Packages</a> or to the <a
+ href="Packages/default">default package</a>. After the fruit is added, add
+ a fruit configuration that configures the component to provide a fruit.
+ These instructions may not apply, depending what kind of fruit you have.
+ </p>
+
+</div>
+</div>
+</body>
+</html>
=== Zope3/lib/python/Zope/App/OFS/Services/Browser/NameConfigurableView.py 1.3 => 1.4 ===
--- /dev/null Sat Dec 21 15:05:47 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/Browser/NameConfigurableView.py Sat Dec 21 15:05:46 2002
@@ -0,0 +1,51 @@
+##############################################################################
+#
+# 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$
+"""
+
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.ComponentArchitecture import getView
+from Zope.App.PageTemplate.ViewPageTemplateFile import ViewPageTemplateFile
+
+class NameConfigurableView(BrowserView):
+
+ indexMacros = index = ViewPageTemplateFile('NameConfigurable.pt')
+
+ 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
+ items.append(self._getItem(name, view, cfg))
+
+ return items
+
+ def _getItem(self, name, view, cfg):
+ # hook for subclasses. returns a dict to append to an item
+ return {"name": name,
+ "active": cfg is not None,
+ "inactive": cfg is None,
+ "view": view,
+ }
+
=== Zope3/lib/python/Zope/App/OFS/Services/Browser/ComponentConfigEdit.pt 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/OFS/Services/Browser/ComponentConfigEdit.pt:1.2 Thu Dec 12 06:32:31 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/Browser/ComponentConfigEdit.pt Sat Dec 21 15:05:46 2002
@@ -22,6 +22,11 @@
tal:content="view/componentPath">foo/bar</a>
</td>
</tr>
+ <tr>
+ <td>Permission</td>
+ <td>
+ <span tal:replace="view/permission">Zope.Foo</span>
+ </td>
</table>
</div>
=== Zope3/lib/python/Zope/App/OFS/Services/Browser/NameComponentConfigurableView.py 1.1 => 1.2 ===
--- Zope3/lib/python/Zope/App/OFS/Services/Browser/NameComponentConfigurableView.py:1.1 Wed Dec 18 15:23:03 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/Browser/NameComponentConfigurableView.py Sat Dec 21 15:05:46 2002
@@ -16,41 +16,23 @@
$Id$
"""
-from Zope.Publisher.Browser.BrowserView import BrowserView
-from Zope.ComponentArchitecture import getView
from Zope.App.Traversing import traverse
from Zope.App.PageTemplate.ViewPageTemplateFile import ViewPageTemplateFile
+from Zope.App.OFS.Services.Browser.NameConfigurableView \
+ import NameConfigurableView
+from Zope.ComponentArchitecture import getView
-
-class NameComponentConfigurableView(BrowserView):
+class NameComponentConfigurableView(NameConfigurableView):
indexMacros = index = ViewPageTemplateFile('NameComponentConfigurable.pt')
- 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
+ def _getItem(self, name, view, cfg):
+ item_dict = NameConfigurableView._getItem(self, name, view, cfg)
+ if cfg is not None:
+ ob = traverse(cfg, cfg.componentPath)
+ url = str(getView(ob, 'absolute_url', self.request))
+ else:
+ url = None
+ item_dict['url'] = url
+ return item_dict