[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/RDB/Browser - AdapterAdd.py:1.2 Connection.py:1.2 TestSQL.py:1.2 __init__.py:1.2 add.pt:1.2 configure.zcml:1.2 connection.pt:1.2 testResults.pt:1.2 testSQL.pt:1.2

Marius Gedminas mgedmin@codeworks.lt
Thu, 12 Dec 2002 06:33:05 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/RDB/Browser
In directory cvs.zope.org:/tmp/cvs-serv21266/lib/python/Zope/App/RDB/Browser

Added Files:
	AdapterAdd.py Connection.py TestSQL.py __init__.py add.pt 
	configure.zcml connection.pt testResults.pt testSQL.pt 
Log Message:
Merge named-component-configuration-branch



=== Zope3/lib/python/Zope/App/RDB/Browser/AdapterAdd.py 1.1 => 1.2 ===
--- /dev/null	Thu Dec 12 06:33:05 2002
+++ Zope3/lib/python/Zope/App/RDB/Browser/AdapterAdd.py	Thu Dec 12 06:32:34 2002
@@ -0,0 +1,42 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Zope database adapter adding view
+
+$Id$
+"""
+from Zope.App.PageTemplate import ViewPageTemplateFile
+from Zope.ComponentArchitecture import getFactory
+
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.App.OFS.Container.IAdding import IAdding
+
+
+class AdapterAdd(BrowserView):
+    """A base class for Zope database adapter adding views.
+
+    Subclasses need to override _adapter_factory_id.
+    """
+
+    __used_for__ = IAdding
+
+    # This needs to be overridden by the actual implementation
+    _adapter_factory_id = None
+
+    add = ViewPageTemplateFile('add.pt')
+
+    def action(self, dsn):
+        factory = getFactory(self, self._adapter_factory_id)
+        adapter = factory(dsn)
+        self.context.add(adapter)
+        self.request.response.redirect(self.context.nextURL())


=== Zope3/lib/python/Zope/App/RDB/Browser/Connection.py 1.1 => 1.2 ===
--- /dev/null	Thu Dec 12 06:33:05 2002
+++ Zope3/lib/python/Zope/App/RDB/Browser/Connection.py	Thu Dec 12 06:32:34 2002
@@ -0,0 +1,35 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Zope database adapter edit view
+
+$Id$
+"""
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.App.RDB.IZopeDatabaseAdapter import IZopeDatabaseAdapter
+
+class Connection(BrowserView):
+
+    __used_for__ = IZopeDatabaseAdapter
+
+    def edit(self, dsn):
+        self.context.setDSN(dsn)
+        return self.request.response.redirect(self.request.URL[-1])
+
+    def connect(self):
+        self.context.connect()
+        return self.request.response.redirect(self.request.URL[-1])
+
+    def disconnect(self):
+        self.context.disconnect()
+        return self.request.response.redirect(self.request.URL[-1])


=== Zope3/lib/python/Zope/App/RDB/Browser/TestSQL.py 1.1 => 1.2 ===
--- /dev/null	Thu Dec 12 06:33:05 2002
+++ Zope3/lib/python/Zope/App/RDB/Browser/TestSQL.py	Thu Dec 12 06:32:34 2002
@@ -0,0 +1,32 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Zope database adapter test view
+
+$Id$
+"""
+from Zope.Proxy.ProxyIntrospection import removeAllProxies
+from Zope.Publisher.Browser.BrowserView import BrowserView
+from Zope.App.RDB.IZopeDatabaseAdapter import IZopeDatabaseAdapter
+from Zope.App.RDB.Util import queryForResults
+
+
+class TestSQL(BrowserView):
+
+    __used_for__ = IZopeDatabaseAdapter
+
+    def getTestResults(self):
+        sql = self.request.form['sql']
+        adapter = removeAllProxies(self.context)
+        result = queryForResults(adapter(), sql)
+        return result


=== Zope3/lib/python/Zope/App/RDB/Browser/__init__.py 1.1 => 1.2 ===
--- /dev/null	Thu Dec 12 06:33:05 2002
+++ Zope3/lib/python/Zope/App/RDB/Browser/__init__.py	Thu Dec 12 06:32:34 2002
@@ -0,0 +1,17 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+"""Common views for Zope database adapters
+
+$Id$
+"""


=== Zope3/lib/python/Zope/App/RDB/Browser/add.pt 1.1 => 1.2 ===
--- /dev/null	Thu Dec 12 06:33:05 2002
+++ Zope3/lib/python/Zope/App/RDB/Browser/add.pt	Thu Dec 12 06:32:34 2002
@@ -0,0 +1,33 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+  <title>Add Relational Database Adapter</title>
+</head>
+<body>
+
+  <div metal:fill-slot="body">
+
+    <form action="action.html" method="post" enctype="multipart/form-data">
+
+      <table>
+        <tbody>
+
+          <tr>
+            <th>Connection URI:</th>
+            <td>
+              Template:
+              dbi://username:password@host:port/dbname;param1=value...<br />
+              <input type="text" name="dsn" size="40" value="dbi://dbname">
+            </td>
+          </tr>
+
+        </tbody>
+      </table>
+
+      <input type="submit" name="add" value="Add" />
+
+    </form>
+
+  </div>
+
+</body>
+</html>


=== Zope3/lib/python/Zope/App/RDB/Browser/configure.zcml 1.1 => 1.2 ===
--- /dev/null	Thu Dec 12 06:33:05 2002
+++ Zope3/lib/python/Zope/App/RDB/Browser/configure.zcml	Thu Dec 12 06:32:34 2002
@@ -0,0 +1,36 @@
+<zopeConfigure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:browser="http://namespaces.zope.org/browser"
+    xmlns:form="http://namespaces.zope.org/form"
+    package="Zope.App.RDB">
+
+<!-- ZopeDatabaseAdapter default views -->
+
+  <browser:defaultView for="Zope.App.RDB.IZopeDatabaseAdapter."
+      name="editForm.html" />
+
+  <browser:menuItems menu="zmi_views" for="Zope.App.RDB.IZopeDatabaseAdapter.">
+    <browser:menuItem title="Edit" action="editForm.html"/>
+    <browser:menuItem title="Test" action="testForm.html"/>
+  </browser:menuItems>
+
+  <browser:view
+      for="Zope.App.RDB.IZopeDatabaseAdapter."
+      permission="Zope.View"
+      factory=".Browser.Connection.">
+    <browser:page name="editForm.html"
+        template="Browser/connection.pt" />
+    <browser:page name="edit.html" attribute="edit" />
+    <browser:page name="connect.html" attribute="connect" />
+    <browser:page name="disconnect.html" attribute="disconnect" />
+  </browser:view>
+
+  <browser:view
+      for="Zope.App.RDB.IZopeDatabaseAdapter."
+      permission="Zope.View"
+      factory=".Browser.TestSQL.">
+    <browser:page name="testForm.html" template="Browser/testSQL.pt" />
+    <browser:page name="test.html" template="Browser/testResults.pt" />
+  </browser:view>
+
+</zopeConfigure>


=== Zope3/lib/python/Zope/App/RDB/Browser/connection.pt 1.1 => 1.2 ===
--- /dev/null	Thu Dec 12 06:33:05 2002
+++ Zope3/lib/python/Zope/App/RDB/Browser/connection.pt	Thu Dec 12 06:32:34 2002
@@ -0,0 +1,38 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+  <title>Add Relational Database Adapter</title>
+</head>
+<body>
+
+  <div metal:fill-slot="body">
+
+    <form action="." method="post" enctype="multipart/form-data">
+    
+      <table>      
+    	<tbody>   
+    	
+    	  <tr>
+    	    <th>Connection URI:</th>
+    	    <td>
+              Template: 
+              dbi://username:password@host:port/dbname;param1=value...<br />
+	      <input type="text" name="dsn" size="40" value=""
+                  tal:attributes="value context/getDSN">  
+            </td>
+    	  </tr>
+    	    	
+    	</tbody>     
+      </table>
+    
+      <input type="submit" name="edit.html:method" value="Save Changes" />
+      <input type="submit" name="connect.html:method" value="Connect"
+          tal:condition="python: not context.isConnected()" />
+      <input type="submit" name="disconnect.html:method" value="Disconnect"
+          tal:condition="python: context.isConnected()" />
+    
+    </form> 
+
+  </div>
+
+</body>
+</html>
\ No newline at end of file


=== Zope3/lib/python/Zope/App/RDB/Browser/testResults.pt 1.1 => 1.2 ===
--- /dev/null	Thu Dec 12 06:33:05 2002
+++ Zope3/lib/python/Zope/App/RDB/Browser/testResults.pt	Thu Dec 12 06:32:34 2002
@@ -0,0 +1,32 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+  <title>Database Adapter - Test Connection</title>
+</head>
+<body>
+
+  <div metal:fill-slot="body">
+
+    <pre tal:content="request/form/sql" />
+
+    <table border="1"
+        tal:define="result view/getTestResults"
+        tal:condition="result">
+      <tbody>
+
+        <tr>
+          <th tal:repeat="field result/columns"
+              tal:content="field">Field Name</th>
+        </tr>
+
+        <tr tal:repeat="row result">
+          <td tal:repeat="field result/columns"
+              tal:content="python: getattr(row, field)">Value</td>
+        </tr>
+
+      </tbody>
+    </table>
+
+  </div>
+
+</body>
+</html>


=== Zope3/lib/python/Zope/App/RDB/Browser/testSQL.pt 1.1 => 1.2 ===
--- /dev/null	Thu Dec 12 06:33:05 2002
+++ Zope3/lib/python/Zope/App/RDB/Browser/testSQL.pt	Thu Dec 12 06:32:34 2002
@@ -0,0 +1,35 @@
+<html metal:use-macro="views/standard_macros/page">
+<head>
+  <title>Database Adapter - Test Connection</title>
+</head>
+<body>
+
+  <div metal:fill-slot="body">
+
+    <form action="." method="post" enctype="multipart/form-data">
+
+      <p>Here you can enter an SQL statement, so you can test the
+      connection.</p>
+
+      <table>
+        <tbody>
+
+          <tr>
+            <th>Query</th>
+            <td>
+              <textarea name="sql" cols="60" rows="10"
+                >SELECT * FROM Table</textarea>
+            </td>
+          </tr>
+
+        </tbody>
+      </table>
+
+      <input type="submit" name="test.html:method" value="Execute" />
+
+    </form>
+
+  </div>
+
+</body>
+</html>