[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - configureConnection.pt:1.1 connection.py:1.6 connection.zcml:1.1 connectionConfiguration.pt:1.1 configure.zcml:1.42 connections.pt:1.4
Guido van Rossum
guido@python.org
Tue, 22 Apr 2003 18:18:10 -0400
Update of /cvs-repository/Zope3/src/zope/app/browser/services
In directory cvs.zope.org:/tmp/cvs-serv29377/zope/app/browser/services
Modified Files:
configure.zcml connections.pt
Added Files:
configureConnection.pt connection.py connection.zcml
connectionConfiguration.pt
Log Message:
New way of configuring db connections. There's still a few loose
ends, but it doen't break any tests, and it works except for one
detail. I'll finish this tomorrow or Thursday.
=== Added File Zope3/src/zope/app/browser/services/configureConnection.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<div metal:fill-slot="body"
i18n:domain="zope"
>
<h2 i18n:translate="">Connection configurations for
<i tal:content="request/name" i18n:name="connection_name">name</i></h2>
<form method="POST"
action="."
tal:attributes="action request/URL"
tal:define="form view/update"
>
<input type="hidden"
name="name"
tal:attributes="value request/name"
/>
<div tal:replace="structure form" />
<input type="submit"
name="submit_update"
value="Update"
i18n:attributes="value form_update"
/>
</form>
</div>
</html>
=== Zope3/src/zope/app/browser/services/connection.py 1.5 => 1.6 ===
--- /dev/null Tue Apr 22 18:18:10 2003
+++ Zope3/src/zope/app/browser/services/connection.py Tue Apr 22 18:17:38 2003
@@ -0,0 +1,76 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Connection configuration support classes.
+
+$Id$
+"""
+
+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
+
+class Connections(BrowserView):
+
+ # self.context is the local connection service
+
+ def getConfigs(self):
+ L = []
+ for name in self.context.listConfigurationNames():
+ cr = self.context.queryConfigurations(name)
+ active = cr.active()
+ d = {"name": name,
+ "url": "",
+ "configurl": ("@@configureConnection.html?name=%s" % name),
+ }
+ if active is not None:
+ d["url"] = str(getView(active.getComponent(),
+ "absolute_url",
+ self.request))
+ L.append((name, d))
+ L.sort()
+ return [d for name, d in L]
+
+class ConfigureConnection(BrowserView):
+
+ def update(self):
+ cr = self.context.queryConfigurations(self.request['name'])
+ form = getView(cr, "ChangeConfigurations", self.request)
+ form.update()
+ return form
+
+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 = []
+ # XXX Somehow this always returns an empty list
+ 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 AddConnectionConfiguration(AddComponentConfiguration):
+
+ def nextURL(self):
+ return "@@connectionConfiguration.html"
=== Added File Zope3/src/zope/app/browser/services/connection.zcml ===
<zopeConfigure xmlns='http://namespaces.zope.org/browser'>
<!-- Browser directives for the connection service -->
<!-- "Add service" menu entry to add a connection service -->
<!-- XXX AFAIK the 'action' value is unused, but must be given -->
<!--ALL DONE-->
<menuItem
for="zope.app.interfaces.container.IAdding"
menu="add_service" title="SQL Connection Service"
action="zope.app.services.ConnectionService"
description="A Persistent SQL Connection Service for TTW development"
permission="zope.ManageServices"
/>
<!-- ZMI tab named "Connections" for the connection service -->
<!--ALL DONE-->
<page
for="zope.app.interfaces.services.connection.ILocalConnectionService"
name="index.html"
template="connections.pt"
class=".connection.Connections"
permission="zope.ManageServices"
menu="zmi_views" title="Connections"
/>
<!-- Browser directives for configuring individual connection objects -->
<!-- Configuration page for connection objects. You get here by
clicking on the (configure) link for a particular connection
in the "Connections" tab of the connection service. It shows
a menu of different configurations, at most one of which
is active. You can activate a different configuration, or
click on an individual configuration to edit it.
(Note that this page doesn't really apply to a single connection,
it applies to a single connection name. -->
<!--ALL DONE-->
<page
for="zope.app.interfaces.services.connection.ILocalConnectionService"
name="configureConnection.html"
template="configureConnection.pt"
class=".connection.ConfigureConnection"
permission="zope.ManageServices"
/>
<!-- ZMI tab named "Configurations" for connection objects.
Given a connection object this lets you view all configurations
available for it. -->
<!--ALL DONE-->
<page
for="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
name="connectionConfiguration.html"
template="connectionConfiguration.pt"
class=".connection.UseConfiguration"
permission="zope.ManageServices"
menu="zmi_views" title="Configurations"
/>
<!-- When creating a new connection object, you are taken to this
form to configure it. The form lets you the connection
parameters, a permission, and a registration status
(Unregistered, Registered or Active). -->
<!--TBD: class AddCacheConfiguration-->
<addform
label="New Connection Configuration"
for="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
name="addConfiguration.html"
schema="zope.app.interfaces.services.connection.IConnectionConfiguration"
class=".connection.AddConnectionConfiguration"
permission="zope.ManageServices"
content_factory="zope.app.services.connection.ConnectionConfiguration"
arguments="name componentPath permission"
set_after_add="status"
fields="name componentPath permission status"
/>
<!-- When editing the configuration of an existing connection object,
you are taken to this form. It is similar to the above add
form, but doesn't let you change the name or path.
(Thus leaving only permission and registration status.) -->
<!--ALL DONE-->
<editform
menu="zmi_views" title="Edit"
label="Connection Configuration"
name="index.html"
schema="zope.app.interfaces.services.connection.IConnectionConfiguration"
permission="zope.ManageServices"
fields="name componentPath permission status"
/>
</zopeConfigure>
=== Added File Zope3/src/zope/app/browser/services/connectionConfiguration.pt ===
<html metal:use-macro="context/@@standard_macros/page">
<body>
<div metal:fill-slot="body">
<p>Configurations for this connection:</p>
<ul>
<li tal:repeat="use view/uses">
<a href="."
tal:attributes="href use/url">
<span tal:condition="use/name">
named <span tal:replace="use/name" />
</span>
</a>
(<span tal:replace="use/status">Active</span>)
</li>
</ul>
<p><a href="addConfiguration.html">Add a configuration for this utility</a>
</div>
</body>
</html>
=== Zope3/src/zope/app/browser/services/configure.zcml 1.41 => 1.42 ===
--- Zope3/src/zope/app/browser/services/configure.zcml:1.41 Tue Apr 22 14:02:55 2003
+++ Zope3/src/zope/app/browser/services/configure.zcml Tue Apr 22 18:17:38 2003
@@ -410,49 +410,7 @@
</menuItems>
-<!-- ConnectionService -->
-
- <menuItems
- menu="zmi_views"
- for="zope.app.interfaces.services.connection.ILocalConnectionService">
- <menuItem title="Connections" action="index.html"/>
- </menuItems>
-
- <page
- for="zope.app.interfaces.services.connection.ILocalConnectionService"
- name="index.html"
- template="connections.pt"
- class=".configuration.NameComponentConfigurableView"
- permission="zope.ManageServices"
- />
-
- <menuItem
- menu="add_service"
- for="zope.app.interfaces.container.IAdding"
- action="ConnectionService"
- title="SQL Connection Service"
- description="A Persistent SQL Connection Service for TTW development"
- />
-
-<!-- ConnectionConfiguration -->
-
- <addform
- schema=
- "zope.app.interfaces.services.connection.IConnectionConfiguration"
- name="ConnectionConfiguration"
- content_factory="zope.app.services.connection.ConnectionConfiguration"
- arguments="name componentPath"
- label="Configure a database connection"
- permission="zope.ManageServices"
- />
-
- <menuItem
- menu="add_configuration"
- for="zope.app.interfaces.container.IAdding"
- action="ConnectionConfiguration"
- title="Connection"
- description="Database Connection"
- />
+<!-- ConnectionService --> <include file="connection.zcml" />
<!-- ServiceManager -->
=== Zope3/src/zope/app/browser/services/connections.pt 1.3 => 1.4 ===
--- Zope3/src/zope/app/browser/services/connections.pt:1.3 Sun Mar 23 11:45:43 2003
+++ Zope3/src/zope/app/browser/services/connections.pt Tue Apr 22 18:17:38 2003
@@ -1,32 +1,44 @@
-<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">Connections configured in this connection service.</h2>
-
- <p metal:fill-slot="empty_text">No connections have been configured</p>
-
- <div metal:fill-slot="extra_top">
-
- <p>For each connection, the connection name is given and all of the
- components registered to provide the connection are shown. You
- may select the component to provide the connection or disable the
- connection.
- </p>
-
- <p>Select a connection name or a component name to visit the connection
- or component.
- </p>
-
- </div>
-
- <p metal:fill-slot="help_text">To configure a connection, add a database
- adapter component to a <em>site-management folder</em>.
- After the component
- is added, add a connection configuration that configures the component to
- provide a connection.
- </p>
+<html metal:use-macro="context/@@standard_macros/page">
+
+<div metal:fill-slot="body"
+ i18n:domain="zope"
+ tal:define="configs view/getConfigs"
+ >
+
+<h2 i18n:translate="">Configured connections in this connection service:</h2>
+
+<table tal:condition="configs">
+ <tbody>
+ <tr tal:repeat="config configs">
+ <td>
+
+ <a href="."
+ tal:condition="config/url"
+ tal:attributes="href config/url"
+ >
+ <span tal:condition="config/name" i18n:translate="">
+ named <span tal:replace="config/name" i18n:name="connection_name" />
+ </span>
+ </a>
+
+ <span tal:condition="not:config/url">
+ <span tal:condition="config/name" i18n:translate="">
+ named <span tal:replace="config/name" i18n:name="connection_name" />
+ </span>
+ <span i18n:translate="">(inactive)</span>
+ </span>
+
+ </td>
+ <td>
+ <a href="."
+ tal:attributes="href config/configurl"
+ i18n:translate=""
+ >(configure)</a>
+ </td>
+ </tr>
+ </tbody>
+</table>
</div>
-</body>
+
</html>