[Zope3-checkins] CVS: Zope3/src/zope/app/rdb/browser - __init__.py:1.1 configure.zcml:1.1 gadflyda.py:1.1 gadflyda.zcml:1.1 rdb.py:1.1 rdbconnection.pt:1.1 rdbtestresults.pt:1.1 rdbtestsql.pt:1.1

Philipp von Weitershausen philikon at philikon.de
Tue Mar 2 08:48:29 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/rdb/browser
In directory cvs.zope.org:/tmp/cvs-serv15174/rdb/browser

Added Files:
	__init__.py configure.zcml gadflyda.py gadflyda.zcml rdb.py 
	rdbconnection.pt rdbtestresults.pt rdbtestsql.pt 
Log Message:
Moved relational database interfaces and browser views to zope.app.rdb.


=== Added File Zope3/src/zope/app/rdb/browser/__init__.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: __init__.py,v 1.1 2004/03/02 13:48:28 philikon Exp $
"""
from zope.proxy import removeAllProxies

from zope.app.rdb.interfaces import IZopeDatabaseAdapter
from zope.app.rdb import queryForResults

class TestSQL:

    __used_for__ = IZopeDatabaseAdapter

    def getTestResults(self):
        sql = self.request.form['sql']
        adapter = removeAllProxies(self.context)
        result = queryForResults(adapter(), sql)
        return result


class Connection:
    __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/src/zope/app/rdb/browser/configure.zcml ===
<zope:configure 
   xmlns:zope="http://namespaces.zope.org/zope"
   xmlns="http://namespaces.zope.org/browser">

<!-- ZopeDatabaseAdapter default views -->

  <!-- XXX need an index.html that gives the source and is the def view -->

  <view
      name="+"
      for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
      class="zope.app.browser.container.adding.Adding" 
      permission="zope.ManageContent" />

  <pages
      for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
      permission="zope.View"
      class=".Connection">

    <page name="editForm.html" template="rdbconnection.pt" 
          menu="zmi_views" title="Edit"/>
    <page name="edit.html" attribute="edit" />
    <page name="connect.html" attribute="connect" />
    <page name="disconnect.html" attribute="disconnect" />
  
  </pages>

  <pages
      for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
      permission="zope.View"
      class=".rdb.TestSQL">
    <page name="testForm.html" template="rdbtestsql.pt"
          menu="zmi_views" title="[test-page-title] Test"/>
    <page name="test.html" template="rdbtestresults.pt" />

  </pages>

  <defaultView 
      for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
      name="editForm.html" />

  <addform
      label="Add Database Connection Registration"
      for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
      name="addRegistration.html"
      schema="zope.app.interfaces.services.utility.IUtilityRegistration"
      class="zope.app.browser.services.utility.AddRegistration"
      permission="zope.ManageServices"
      content_factory="zope.app.services.utility.UtilityRegistration"
      arguments="name interface componentPath"
      set_after_add="status"
      fields="name interface componentPath permission status" 
      usage="addingdialog" />

  <zope:include file="gadflyda.zcml" />

</zope:configure>


=== Added File Zope3/src/zope/app/rdb/browser/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.
#
##############################################################################
"""Gadfly DA View Classes

$Id: gadflyda.py,v 1.1 2004/03/02 13:48:28 philikon Exp $
"""
from zope.app.rdb.browser.rdb import AdapterAdd

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/rdb/browser/gadflyda.zcml ===
<zope:configure 
   xmlns:zope="http://namespaces.zope.org/zope"
   xmlns="http://namespaces.zope.org/browser">

  <addform
      name="AddGadflyDA"
      schema="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
      label="Add Gadfly Database Adapter"
      content_factory="zope.app.rdb.gadflyda.GadflyAdapter"
      arguments="dsn"
      fields="dsn"
      permission="zope.ManageContent"
      usage="addingdialog" />

  <addMenuItem
    title="Gadfly DA" 
    description="A DA for the built-in 100% Pure Python Gadfly Database"
    class="zope.app.rdb.gadflyda.GadflyAdapter"
    permission="zope.ManageServices"
    view="AddGadflyDA"
  />

</zope:configure>


=== Added File Zope3/src/zope/app/rdb/browser/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 2004/03/02 13:48:28 philikon Exp $
"""
from zope.proxy import removeAllProxies

from zope.app.rdb.interfaces import IZopeDatabaseAdapter
from zope.app.rdb import queryForResults

class TestSQL:

    __used_for__ = IZopeDatabaseAdapter

    def getTestResults(self):
        sql = self.request.form['sql']
        adapter = removeAllProxies(self.context)
        result = queryForResults(adapter(), sql)
        return result


class Connection:
    __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/src/zope/app/rdb/browser/rdbconnection.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
  <title metal:fill-slot="title" i18n:translate="">
    Edit Relational Database Adapter
  </title>
</head>

<body>
<div metal:fill-slot="body">

  <form action="." method="post" enctype="multipart/form-data">
  
    <div class="row">
      <div class="label" i18n:translate="">Connection URI:</div>
      <div class="field">
        <span i18n:translate="">
          Template:
          dbi://username:password@host:port/dbname;param1=value...
        </span>
        <br />
        <input type="text" name="dsn" size="40" value=""
               tal:attributes="value context/dsn" />
      </div>
    </div>

    <div class="row">
      <div class="controls">
        <input type="submit" name="edit.html:method" value="Save Changes"
               i18n:attributes="value save-changes-button"/>
        <input type="submit" name="connect.html:method" value="Connect"
               tal:condition="python: not context.isConnected()"
               i18n:attributes="value connect-button"/>
        <input type="submit" name="disconnect.html:method" value="Disconnect"
               tal:condition="python: context.isConnected()"
               i18n:attributes="value disconnect-button"/>
      </div>
    </div>

  </form> 

</div>
</body>
</html>


=== Added File Zope3/src/zope/app/rdb/browser/rdbtestresults.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
  <title metal:fill-slot="title" i18n:translate="">
    Database Adapter - Test Connection
  </title>
</head>

<body>
<div metal:fill-slot="body">

  <div i18n:translate="">Executed Query:</div>
  <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/rdb/browser/rdbtestsql.pt ===
<html metal:use-macro="views/standard_macros/page">
<head>
  <title metal:fill-slot="title" i18n:translate="">
    Database Adapter - Test Connection
  </title>
</head>

<body>
<div metal:fill-slot="body">

  <form action="." method="post" enctype="multipart/form-data">

    <p i18n:translate="">
      Here you can enter an SQL statement, so you can test the
      connection.</p>

    <div class="row">
      <div class="label" i18n:translate="">Query</div>
      <div class="field">
        <textarea name="sql" cols="60" rows="10"
          >SELECT * FROM Table</textarea>
      </div>
    </div>

    <div class="row">
      <div class="controls">
        <input type="submit" name="test.html:method" value="Execute" 
               i18n:attributes="value execute-button"/>
      </div>
    </div>

  </form>

</div>
</body>
</html>




More information about the Zope3-Checkins mailing list