[Zope3-checkins] CVS: Zope3/src/zope/app/browser/rdb - gadflyda.zcml:1.1 __init__.py:1.2 configure.zcml:1.7 rdb.py:1.5 rdbconnection.pt:1.6 rdbadd.pt:NONE

Stephan Richter srichter at cosmos.phy.tufts.edu
Tue Aug 19 04:10:09 EDT 2003


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

Modified Files:
	__init__.py configure.zcml rdb.py rdbconnection.pt 
Added Files:
	gadflyda.zcml 
Removed Files:
	rdbadd.pt 
Log Message:
Heads up, this is the beginning of Servicegeddon. We noticed that named 
components are a pain in the butt and that we can simpluify our code a lot
by making these named components local utilities. 

So I started with the SQL Connection service and database adapters and 
simplified the code greatly. Database Adaptors are now just simple 
utilities.

I also took the oppurtunity and updated all database adapters. 

This change is not backward compatible and you will have to toss your ZODB.
Although all tests pass, I expect there to be some hickups, so feel free to 
fix or report these. 

Next I will fix up the front screen a bit and try to factor some other 
pieces. I also still miss some functionality in the Utilities, which I plan
to add.




=== Added File Zope3/src/zope/app/browser/rdb/gadflyda.zcml ===
<configure xmlns="http://namespaces.zope.org/browser">

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

  <!-- Menu entry for "add component" menu -->
  <menuItem
      for="zope.app.interfaces.container.IAdding"
      menu="add_component"
      action="AddGadflyDA"
      title="Gadfly DA" 
      description="A DA for the built-in 100% Pure Python Gadfly Database" />

  <!-- Menu entry for "add utility" menu -->
  <menuItem
      for="zope.app.interfaces.container.IAdding"
      menu="add_utility"
      action="AddGadflyDA"
      title="Gadfly DA" 
      description="A DA for the built-in 100% Pure Python Gadfly Database" />

  <!-- Menu entry for "add connection" menu -->
  <menuItem
      for="zope.app.interfaces.container.IAdding"
      menu="add_connection"
      action="AddGadflyDA"
      title="Gadfly DA" 
      description="A DA for the built-in 100% Pure Python Gadfly Database" />

</configure>


=== Zope3/src/zope/app/browser/rdb/__init__.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/browser/rdb/__init__.py:1.1	Fri Feb  7 10:48:39 2003
+++ Zope3/src/zope/app/browser/rdb/__init__.py	Tue Aug 19 03:09:33 2003
@@ -1,2 +1,51 @@
+##############################################################################
 #
-# This file is necessary to make this directory a package.
+# 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$
+"""
+from zope.component import getFactory
+from zope.proxy import removeAllProxies
+
+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:
+
+    __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])


=== Zope3/src/zope/app/browser/rdb/configure.zcml 1.6 => 1.7 ===
--- Zope3/src/zope/app/browser/rdb/configure.zcml:1.6	Thu Aug  7 13:40:48 2003
+++ Zope3/src/zope/app/browser/rdb/configure.zcml	Tue Aug 19 03:09:33 2003
@@ -4,11 +4,17 @@
 
   <!-- XXX need an index.html that gives the source and is the def view -->
 
+  <view
+      name="+"
+      for="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
+      class="zope.app.browser.container.adding.Adding" 
+      permission="zope.ManageContent" />
+
   <pages
       for="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
       permission="zope.View"
-      class=".rdb.Connection"
-      >
+      class=".Connection">
+
     <page name="editForm.html" template="rdbconnection.pt" 
           menu="zmi_views" title="Edit"/>
     <page name="edit.html" attribute="edit" />
@@ -31,33 +37,18 @@
       for="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
       name="editForm.html" />
 
-<!-- Gadfly DA -->
+  <addform
+      label="Add Database Connection Registration"
+      for="zope.app.interfaces.rdb.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" />
 
-  <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>
-
-  <!-- Menu entry for "add component" menu -->
-  <menuItem
-      menu="add_component"
-      for="zope.app.interfaces.container.IAdding"
-      title="Gadfly DA" 
-      description="A DA for the built-in 100% Pure Python Gadfly Database"
-      action="zope.app.rdb.gadflyda.GadflyAdapter" />
-
-  <!-- Menu entry for "add connection" menu -->
-  <menuItem
-      menu="add_connection"
-      for="zope.app.interfaces.container.IAdding"
-      title="Gadfly DA" 
-      description="A DA for the built-in 100% Pure Python Gadfly Database"
-      action="zope.app.rdb.gadflyda.GadflyAdapter" />
+  <include file="gadflyda.zcml" />
 
 </configure>


=== Zope3/src/zope/app/browser/rdb/rdb.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/browser/rdb/rdb.py:1.4	Thu Aug  7 13:40:48 2003
+++ Zope3/src/zope/app/browser/rdb/rdb.py	Tue Aug 19 03:09:33 2003
@@ -49,21 +49,3 @@
     def disconnect(self):
         self.context.disconnect()
         return self.request.response.redirect(self.request.URL[-1])
-
-class AdapterAdd:
-    """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())


=== Zope3/src/zope/app/browser/rdb/rdbconnection.pt 1.5 => 1.6 ===
--- Zope3/src/zope/app/browser/rdb/rdbconnection.pt:1.5	Thu Aug  7 13:40:48 2003
+++ Zope3/src/zope/app/browser/rdb/rdbconnection.pt	Tue Aug 19 03:09:33 2003
@@ -19,7 +19,7 @@
         </span>
         <br />
         <input type="text" name="dsn" size="40" value=""
-               tal:attributes="value context/getDSN" />
+               tal:attributes="value context/dsn" />
       </div>
     </div>
 

=== Removed File Zope3/src/zope/app/browser/rdb/rdbadd.pt ===




More information about the Zope3-Checkins mailing list