[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser - AdapterAdd.py:1.1 Connection.py:1.1 TestSQL.py:1.1 add.pt:1.1 connection.pt:1.1 testResults.pt:1.1 testSQL.pt:1.1 Adding.py:1.2 ConnectionAdding.py:1.2 __init__.py:1.2 configure.zcml:1.3
Stephan Richter
srichter@cbu.edu
Wed, 10 Jul 2002 19:52:19 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv6998/Views/Browser
Modified Files:
Adding.py ConnectionAdding.py __init__.py configure.zcml
Added Files:
AdapterAdd.py Connection.py TestSQL.py add.pt connection.pt
testResults.pt testSQL.pt
Log Message:
Finished up the Connectoin Service and provide views for Database Adapters.
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/AdapterAdd.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: AdapterAdd.py,v 1.1 2002/07/10 23:52:18 srichter Exp $
"""
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):
"""Provide a user interface for adding a contact"""
__used_for__ = IAdding
# This needs to be overridden by the actual implementation
_adapter_factory_id = None
add = ViewPageTemplateFile('add.pt')
# action method
def action(self, dsn):
"Add a contact"
factory = getFactory(self, self._adapter_factory_id)
adapter = factory(dsn)
self.context.add(adapter)
self.request.response.redirect(self.context.nextURL())
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/Connection.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.
#
##############################################################################
"""Connection Management GUI
$Id: Connection.py,v 1.1 2002/07/10 23:52:18 srichter Exp $
"""
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])
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/TestSQL.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: TestSQL.py,v 1.1 2002/07/10 23:52:18 srichter Exp $
"""
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
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/add.pt ===
<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>
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/connection.pt ===
<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>
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/testResults.pt ===
<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/names"
tal:content="field">Field Name</th>
</tr>
<tr tal:repeat="row result">
<td tal:repeat="field result/names"
tal:content="python: getattr(row, field)">Value</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>
=== Added File Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/testSQL.pt ===
<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>SQLCode:</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>
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/Adding.py 1.1 => 1.2 ===
from Zope.App.OFS.Container.Views.Browser.Adding import Adding as ContentAdding
-class ConnectionAdding(ContentAdding):
- """Adding component for service containers
- """
+class Adding(ContentAdding):
+ """Adding component for service containers"""
menu_id = "add_connection"
-
-__doc__ = ConnectionAdding.__doc__ + __doc__
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/ConnectionAdding.py 1.1 => 1.2 ===
"""
from Zope.App.OFS.Container.Views.Browser.Adding import Adding
-from Zope.App.OFS.Services.ConnectionService.IConnectionAdding import IConnectionAdding
+from Zope.App.OFS.Services.ConnectionService.IConnectionAdding import \
+ IConnectionAdding
class ConnectionAdding(Adding):
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/__init__.py 1.1 => 1.2 ===
##############################################################################
#
-# Copyright (c) 2002 Zope Corporation and Contributors.
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
@@ -11,14 +11,4 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""XXX short summary goes here.
-XXX longer description goes here.
-
-$Id$
-"""
-
-
-
-
-
=== Zope3/lib/python/Zope/App/OFS/Services/ConnectionService/Views/Browser/configure.zcml 1.2 => 1.3 ===
<zopeConfigure
- xmlns='http://namespaces.zope.org/zope'
- xmlns:browser='http://namespaces.zope.org/browser'
->
-
- <browser:defaultView
- for="Zope.App.OFS.Services.ConnectionService.IConnectionManager."
- name="index.html"
- />
-
- <browser:view
- for="Zope.App.RDB.IConnectionService."
- permission="Zope.ManageServices"
- factory="Zope.App.OFS.Container.Views.Browser.Contents."
- >
-
- <browser:page name="index.html"
- attribute="index"
- />
-
- </browser:view>
-
- <browser:view
- name="+"
- permission="Zope.ManageServices"
- for="Zope.App.OFS.Services.ConnectionService.IConnectionManager."
- factory=".Adding.ConnectionAdding">
-
- <browser:page name="index.html" attribute="index" />
- <browser:page name="action.html" attribute="action" />
-
- </browser:view>
-
- <browser:menuItems menu="zmi_views"
- for="Zope.App.OFS.Services.ConnectionService.IConnectionManager.">
- <browser:menuItem title="Contents" action="@@index.html"/>
- </browser:menuItems>
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ package="Zope.App.OFS.Services.ConnectionService">
+
+<!-- Handle all Connection Service configuration -->
+
+<browser:menu id="add_connection"
+ title="Menu for adding new database connections." />
+
+<browser:defaultView
+ for=".ConnectionService.ILocalConnectionService"
+ name="index.html" />
+
+<browser:view
+ permission="Zope.ManageServices"
+ for=".ConnectionService.ILocalConnectionService"
+ factory="Zope.App.OFS.Container.Views.Browser.Contents.">
+
+ <browser:page name="index.html" attribute="index" />
+
+</browser:view>
+
+<browser:view
+ name="+"
+ for=".ConnectionService.ILocalConnectionService"
+ permission="Zope.ManageContent"
+ factory=".Views.Browser.Adding." >
+
+ <browser:page name="index.html" attribute="index" />
+ <browser:page name="action.html" attribute="action" />
+
+</browser:view>
+
+<browser:menuItem menu="add_service" for="Zope.App.OFS.Container.IAdding."
+ action="ConnectionService" title="RDBMS Connection Service"
+ description="A Persistent RDBMS Connection Service for TTW development" />
+
+
+<!-- Handle all generic Database Adapter configuration -->
+
+<browser:defaultView for="Zope.App.RDB.IZopeDatabaseAdapter."
+ name="editForm.html" />
+
+<browser:view
+ for="Zope.App.RDB.IZopeDatabaseAdapter."
+ permission="Zope.View"
+ factory=".Views.Browser.Connection.">
+ <browser:page name="editForm.html"
+ template="Views/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=".Views.Browser.TestSQL.">
+ <browser:page name="testForm.html" template="Views/Browser/testSQL.pt" />
+ <browser:page name="test.html" template="Views/Browser/testResults.pt" />
+</browser:view>
+
+<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>
</zopeConfigure>