[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser - AddConnectionConfiguration.py:1.1 ConnectionConfigEdit.pt:1.1 ConnectionConfigEditPart.pt:1.1 ConnectionConfigSummary.pt:1.1 ConnectionConfigURL.py:1.1 Connections.pt:1.1 Connections.py:1.1 add_config.pt:1.1 configure.zcml:1.6

Viktorija Zaksiene ryzaja@codeworks.lt
Mon, 9 Dec 2002 10:26:43 -0500


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

Modified Files:
	configure.zcml 
Added Files:
	AddConnectionConfiguration.py ConnectionConfigEdit.pt 
	ConnectionConfigEditPart.pt ConnectionConfigSummary.pt 
	ConnectionConfigURL.py Connections.pt Connections.py 
	add_config.pt 
Log Message:
ConnectionService is no longer a container of database adapters; now the
latter are added directly into a package and bound to the connection service
via the common configuration mechanism.



=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/AddConnectionConfiguration.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.
# 
##############################################################################
"""XXX short summary goes here.

XXX longer description goes here.

$Id: AddConnectionConfiguration.py,v 1.1 2002/12/09 15:26:42 ryzaja 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.ConnectionService.IConnectionConfiguration \
     import IConnectionConfiguration
from Zope.App.OFS.Services.ConnectionService.ConnectionConfiguration \
     import ConnectionConfiguration
from Zope.App.RDB.IZopeDatabaseAdapter import IZopeDatabaseAdapter

class AddConnectionConfiguration(BrowserView):

    def __init__(self, *args):
        super(AddConnectionConfiguration, self).__init__(*args)
        setUpWidgets(self, IConnectionConfiguration)

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

    def action(self, component_path):
        cd = ConnectionConfiguration(None, component_path)
        cd = self.context.add(cd)
        getWidgetsDataForContent(self, IConnectionConfiguration, cd)
        self.request.response.redirect(self.context.nextURL())



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

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

      <table metal:fill-slot="extra_info">
        <tr>
          <td>Connection Name</td>
          <td tal:content="context/connectionName">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/ConnectionService/Views/Browser/ConnectionConfigEditPart.pt ===
<div metal:use-macro="view/generated_form/macros/formbody">

  <h5 metal:fill-slot="heading">
      <span tal:replace="context/connectionName">Connection Name</span> Connection
  </h5>

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

</div>


=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/ConnectionConfigSummary.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/ConnectionService/Views/Browser/ConnectionConfigURL.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: ConnectionConfigURL.py,v 1.1 2002/12/09 15:26:42 ryzaja Exp $
"""

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

__metaclass__ = type

class ConnectionConfigURL:
    """A view that provides an absolute URL from context.componentPath"""

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

__doc__ = ConnectionConfigURL.__doc__ + __doc__



=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/Connections.pt ===
<html metal:use-macro="views/standard_macros/page">
<body metal:fill-slot="body" tal:define="connections view/update">

  <h2>Connections configured in this connection service.</h2>

    <p tal:condition="not:connections">
         No connections have been configured
    </p>

    <div tal:condition="connections">

        <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>

        <form action="." method="post"
              tal:attributes="action request/URL">

        <table width="100%">

           <tr tal:repeat="connection connections">
             <td valign="top" align="right">
                <a href="Roles"
                   tal:content="connection/name"
                   tal:attributes="href connection/name"
                   tal:condition="connection/active"
                   >Roles</a>
                <span tal:replace="connection/name" 
                      tal:condition="connection/inactive" />
             </td>
             <td tal:content="structure connection/view">
             </td>
           </tr>

        </table>

        <input type=submit name="submit_update" value="Update"><br>

        </form>

    </div>

    <p>To configure a connection, 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 connection configuration that configures the
       component to provide a connection.
  </p>

</body>
</html>


=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/Connections.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.
# 
##############################################################################
"""

$Id: Connections.py,v 1.1 2002/12/09 15:26:42 ryzaja Exp $
"""

from Zope.Publisher.Browser.BrowserView import BrowserView
from Zope.ComponentArchitecture import getView

class Connections(BrowserView):

    def update(self):

        conn_names = list(self.context.getAvailableConnections())
        conn_names.sort()

        connections = []
        for conn_name in conn_names:
            registry = self.context.queryConfigurations(conn_name)
            view = getView(registry, "ChangeConfigurations", self.request)
            view.setPrefix(conn_name)
            view.update()
            active = registry.active() is not None
            connections.append(
                {"name": conn_name,
                 "active": active,
                 "inactive": not active,
                 "view": view,
                 })

        return connections
    


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

<form action="finish.html" method="post">
  <table>
     <tr>
       <td>Connection Name</td>
       <td tal:content="structure view/connectionName"><input type="text"></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/ConnectionService/Views/Browser/configure.zcml 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/configure.zcml:1.5	Thu Oct  3 09:47:09 2002
+++ Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/configure.zcml	Mon Dec  9 10:26:42 2002
@@ -1,46 +1,88 @@
 <zopeConfigure
-   xmlns="http://namespaces.zope.org/zope"
-   xmlns:browser="http://namespaces.zope.org/browser"
-   package="Zope.App.OFS.Services.ConnectionService">
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:browser="http://namespaces.zope.org/browser"
+    xmlns:form="http://namespaces.zope.org/form"
+    package="Zope.App.OFS.Services.ConnectionService">
 
-<!-- Handle all Connection Service configuration -->
-
-  <browser:menu id="add_connection" 
-      title="Menu for adding new database connections." />
+<!-- ConnectionService -->
 
   <browser:defaultView 
-     for=".ConnectionService.ILocalConnectionService"
-     name="contents.html" />
+      for=".IConnectionManager"
+      name="index.html" />
 
   <browser:view 
-     permission="Zope.ManageServices" 
-     for=".ConnectionService.ILocalConnectionService"
-     factory="Zope.App.OFS.Container.Views.Browser.Contents.">
+      for=".IConnectionManager"
+      name="index.html"
+      template="Views/Browser/Connections.pt"
+      class=".Views.Browser.Connections."
+      permission="Zope.ManageServices" />
+
+  <browser:menuItem
+      menu="add_component"
+      for="Zope.App.OFS.Container.IAdding."
+      action="ConnectionService"
+      title="RDBMS Connection Service"
+      description="A Persistent RDBMS Connection Service for TTW development"
+      />
 
-     <browser:page name="contents.html" attribute="contents" />
-     <browser:page name="removeObjects.html" attribute="removeObjects" />
+<!-- ConnectionConfiguration -->
 
-  </browser:view>
+  <browser:defaultView 
+      for=".IConnectionConfiguration."
+      name="index.html" />
+
+  <browser:menuItems menu="zmi_views" for=".IConnectionConfiguration.">
+    <browser:menuItem title="Edit" action="index.html"/>
+  </browser:menuItems>
+
+  <form:edit
+      for=".IConnectionConfiguration."
+      name="index.html"
+      schema="Zope.App.OFS.Services.ConfigurationInterfaces.IConfiguration."
+      label="Connection Configuration"
+      permission="Zope.ManageServices"
+      template="Views/Browser/ConnectionConfigEdit.pt"
+      />
+
+  <form:edit
+      for=".IConnectionConfiguration."
+      name="ItemEdit"
+      schema= 
+        "Zope.App.OFS.Services.ConfigurationInterfaces.IConfigurationSummary."
+      label="Service Configuration"
+      template="Views/Browser/ConnectionConfigEditPart.pt"
+      class=".Views.Browser.ConnectionConfigURL."
+      permission = "Zope.ManageServices"
+      />
 
   <browser:view
-      name="+"  
-      for=".ConnectionService.ILocalConnectionService"
-      permission="Zope.ManageContent"
-      factory=".Views.Browser.Adding." >
+      for=".IConnectionConfiguration."
+      name="ConfigurationSummary"
+      template="Views/Browser/ConnectionConfigSummary.pt"
+      class=".Views.Browser.ConnectionConfigURL."
+      permission="Zope.ManageServices" 
+      />  
 
-    <browser:page name="index.html"  attribute="index" />
-    <browser:page name="action.html" attribute="action" />
+  <browser:view 
+      for="Zope.App.OFS.Container.IAdding."
+      name="ConnectionConfiguration"
+      factory=".Views.Browser.AddConnectionConfiguration."
+      permission="Zope.ManageServices">
 
-  </browser:view>
+    <browser:page name="add.html" template="Views/Browser/add_config.pt" />
+    <browser:page name="finish.html" attribute="action" />
 
-  <browser:menuItem menu="add_component" for="Zope.App.OFS.Container.IAdding."
-       action="ConnectionService"  title="RDBMS Connection Service"
-       description="A Persistent RDBMS Connection Service for TTW
-       development"
-       />
+  </browser:view>
 
+  <browser:menuItem
+      menu="add_configuration"
+      for="Zope.App.OFS.Container.IAdding."
+      action="ConnectionConfiguration"
+      title="Connection"
+      description="Database Connection"
+      />
 
-  <!-- Handle all generic Database Adapter configuration -->
+<!-- ZopeDatabaseAdapter default views -->
 
   <browser:defaultView for="Zope.App.RDB.IZopeDatabaseAdapter." 
       name="editForm.html" />