[Zope3-checkins] CVS: Zope3/src/zope/app/browser/rdb - __init__.py:1.1 configure.zcml:1.1 gadflyda.py:1.1 rdb.py:1.1 rdbadd.pt:1.1 rdbconnection.pt:1.1 rdbtestresults.pt:1.1 rdbtestsql.pt:1.1
Jim Fulton
jim@zope.com
Fri, 7 Feb 2003 10:48:40 -0500
Update of /cvs-repository/Zope3/src/zope/app/browser/rdb
In directory cvs.zope.org:/tmp/cvs-serv23045/browser/rdb
Added Files:
__init__.py configure.zcml gadflyda.py rdb.py rdbadd.pt
rdbconnection.pt rdbtestresults.pt rdbtestsql.pt
Log Message:
Cleaned up the layout of the browser configuration a bit.
Moved some container traversal browser configs from zope.app.container
to zope.app.browser.
=== Added File Zope3/src/zope/app/browser/rdb/__init__.py ===
#
# This file is necessary to make this directory a package.
=== Added File Zope3/src/zope/app/browser/rdb/configure.zcml ===
<zopeConfigure xmlns='http://namespaces.zope.org/browser'>
<!-- ZopeDatabaseAdapter default views -->
<!-- XXX need an index.html that gives the source and is the def view -->
<defaultView for="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
name="editForm.html" />
<menuItems menu="zmi_views"
for="zope.app.interfaces.rdb.IZopeDatabaseAdapter">
<menuItem title="Edit" action="editForm.html"/>
<menuItem title="Test" action="testForm.html"/>
</menuItems>
<pages
for="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
permission="zope.View"
class=".rdb.Connection"
>
<page name="editForm.html"
template="rdbconnection.pt" />
<page name="edit.html" attribute="edit" />
<page name="connect.html" attribute="connect" />
<page name="disconnect.html" attribute="disconnect" />
</pages>
<pages
for="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
permission="zope.View"
class=".rdb.TestSQL"
>
<page name="testForm.html" template="rdbtestsql.pt" />
<page name="test.html" template="rdbtestresults.pt" />
</pages>
<!-- Gadfly DA -->
<view
name="zope.app.rdb.gadflyda.GadflyAdapter"
for="zope.app.interfaces.container.IAdding"
class=".gadflyda.GadflyDAAddView"
permission="zope.ManageServices">
<page name="+" attribute="add" />
<page name="action.html" attribute="action" />
</view>
<menuItem menu="add_component"
for="zope.app.interfaces.container.IAdding"
title="Gadfly DA"
action="zope.app.rdb.gadflyda.GadflyAdapter"
description="A Gadfly Database Adapter"/>
</zopeConfigure>
=== Added File Zope3/src/zope/app/browser/rdb/gadflyda.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: gadflyda.py,v 1.1 2003/02/07 15:48:39 jim Exp $
"""
from zope.app.browser.rdb.rdb import AdapterAdd
from zope.app.interfaces.container import IAdding
class GadflyDAAddView(AdapterAdd):
"""Provide a user interface for adding a Gadfly DA"""
# This needs to be overridden by the actual implementation
_adapter_factory_id = "GadflyDA"
=== Added File Zope3/src/zope/app/browser/rdb/rdb.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.
#
##############################################################################
"""Zope database adapter views
$Id: rdb.py,v 1.1 2003/02/07 15:48:39 jim Exp $
"""
from zope.component import getFactory
from zope.proxy.introspection import removeAllProxies
from zope.publisher.browser import BrowserView
from zope.app.interfaces.container import IAdding
from zope.app.interfaces.rdb import IZopeDatabaseAdapter
from zope.app.pagetemplate.viewpagetemplatefile import ViewPageTemplateFile
from zope.app.rdb 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
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])
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('rdbadd.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())
=== Added File Zope3/src/zope/app/browser/rdb/rdbadd.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/src/zope/app/browser/rdb/rdbconnection.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/src/zope/app/browser/rdb/rdbtestresults.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/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>
=== Added File Zope3/src/zope/app/browser/rdb/rdbtestsql.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>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>