[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/ Tightened the permission declarations in zope.app.rdb.

Jim Fulton jim at zope.com
Thu Aug 12 18:25:31 EDT 2004


Log message for revision 27088:
  Tightened the permission declarations in zope.app.rdb.
  
  This required refactoring some of the interfaces a bit.
  


Changed:
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/__init__.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/__init__.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/configure.zcml
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/gadflyda.zcml
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/rdb.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/configure.zcml
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/gadflyda.zcml
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/gadflymeta.py
  U   Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/interfaces.py


-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/__init__.py	2004-08-12 21:02:48 UTC (rev 27087)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/__init__.py	2004-08-12 22:25:31 UTC (rev 27088)
@@ -36,7 +36,9 @@
 from zope.app.rdb.interfaces import DatabaseException
 from zope.app.rdb.interfaces import IResultSet
 from zope.app.rdb.interfaces import IZopeConnection, IZopeCursor
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter, ISQLCommand
+from zope.app.rdb.interfaces import ISQLCommand
+from zope.app.rdb.interfaces import IManageableZopeDatabaseAdapter
+from zope.app.rdb.interfaces import IZopeDatabaseAdapter
 from zope.app.rdb.interfaces import IGlobalConnectionService
 
 
@@ -108,7 +110,7 @@
 
 class ZopeDatabaseAdapter(Persistent, Contained):
 
-    implements(IZopeDatabaseAdapter)
+    implements(IManageableZopeDatabaseAdapter)
     _v_connection =  None
 
     def __init__(self, dsn):
@@ -119,16 +121,13 @@
         conn_info = parseDSN(self.dsn)
 
     def setDSN(self, dsn):
-        'See IZopeDatabaseAdapter'
         assert dsn.startswith('dbi://'), "The DSN has to start with 'dbi://'"
         self.dsn = dsn
 
     def getDSN(self):
-        'See IZopeDatabaseAdapter'
         return self.dsn
 
     def connect(self):
-        'See IZopeDatabaseAdapter'
         if not self.isConnected():
             try:
                 self._v_connection = ZopeConnection(
@@ -142,18 +141,15 @@
 
 
     def disconnect(self):
-        'See IZopeDatabaseAdapter'
         if self.isConnected():
             self._v_connection.close()
             self._v_connection = None
 
     def isConnected(self):
-        'See IZopeDatabaseAdapter'
         return hasattr(self, '_v_connection') and \
                self._v_connection is not None
 
     def __call__(self):
-        'See IZopeDatabaseAdapter'
         self.connect()
         return self._v_connection
 

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/__init__.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/__init__.py	2004-08-12 21:02:48 UTC (rev 27087)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/__init__.py	2004-08-12 22:25:31 UTC (rev 27088)
@@ -1,47 +1 @@
-##############################################################################
 #
-# 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.1 (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.proxy import removeAllProxies
-
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter
-from zope.app.rdb import queryForResults
-
-class TestSQL(object):
-
-    __used_for__ = IZopeDatabaseAdapter
-
-    def getTestResults(self):
-        sql = self.request.form['sql']
-        adapter = removeAllProxies(self.context)
-        result = queryForResults(adapter(), sql)
-        return result
-
-
-class Connection(object):
-    __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])

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/configure.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/configure.zcml	2004-08-12 21:02:48 UTC (rev 27087)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/configure.zcml	2004-08-12 22:25:31 UTC (rev 27088)
@@ -17,12 +17,12 @@
       name="+"
       for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
       class="zope.app.container.browser.adding.Adding" 
-      permission="zope.ManageContent" />
+      permission="zope.ManageServices" />
 
   <pages
-      for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
-      permission="zope.View"
-      class=".Connection">
+      for="zope.app.rdb.interfaces.IManageableZopeDatabaseAdapter"
+      permission="zope.ManageServices"
+      class=".rdb.Connection">
 
     <page name="editForm.html" template="rdbconnection.pt" 
           menu="zmi_views" title="Edit"/>
@@ -33,8 +33,8 @@
   </pages>
 
   <pages
-      for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
-      permission="zope.View"
+      for="zope.app.rdb.interfaces.IManageableZopeDatabaseAdapter"
+      permission="zope.ManageServices"
       class=".rdb.TestSQL">
     <page name="testForm.html" template="rdbtestsql.pt"
           menu="zmi_views" title="[test-page-title] Test"/>
@@ -43,12 +43,12 @@
   </pages>
 
   <defaultView 
-      for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
+      for="zope.app.rdb.interfaces.IManageableZopeDatabaseAdapter"
       name="editForm.html" />
 
   <addform
       label="Add Database Connection Registration"
-      for="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
+      for="zope.app.rdb.interfaces.IManageableZopeDatabaseAdapter"
       name="addRegistration.html"
       schema="zope.app.utility.interfaces.IUtilityRegistration"
       class="zope.app.utility.browser.AddRegistration"

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/gadflyda.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/gadflyda.zcml	2004-08-12 21:02:48 UTC (rev 27087)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/gadflyda.zcml	2004-08-12 22:25:31 UTC (rev 27088)
@@ -4,7 +4,7 @@
 
   <addform
       name="AddGadflyDA"
-      schema="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
+      schema="zope.app.rdb.interfaces.IManageableZopeDatabaseAdapter"
       label="Add Gadfly Database Adapter"
       content_factory="zope.app.rdb.gadflyda.GadflyAdapter"
       arguments="dsn"

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/rdb.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/rdb.py	2004-08-12 21:02:48 UTC (rev 27087)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/browser/rdb.py	2004-08-12 22:25:31 UTC (rev 27088)
@@ -15,24 +15,21 @@
 
 $Id$
 """
-from zope.proxy import removeAllProxies
-
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter
+from zope.app.rdb.interfaces import IManageableZopeDatabaseAdapter
 from zope.app.rdb import queryForResults
 
 class TestSQL(object):
 
-    __used_for__ = IZopeDatabaseAdapter
+    __used_for__ = IManageableZopeDatabaseAdapter
 
     def getTestResults(self):
         sql = self.request.form['sql']
-        adapter = removeAllProxies(self.context)
-        result = queryForResults(adapter(), sql)
+        result = queryForResults(self.context(), sql)
         return result
 
 
 class Connection(object):
-    __used_for__ = IZopeDatabaseAdapter
+    __used_for__ = IManageableZopeDatabaseAdapter
 
     def edit(self, dsn):
         self.context.setDSN(dsn)

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/configure.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/configure.zcml	2004-08-12 21:02:48 UTC (rev 27087)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/configure.zcml	2004-08-12 22:25:31 UTC (rev 27088)
@@ -3,6 +3,11 @@
     i18n_domain="zope"
     >
 
+  <permission
+      id="zope.app.rdb.Use"
+      title="[zope.app.rdb.Use] Use Database Connections"
+      />
+
   <content class="zope.app.rdb.ZopeConnection">
     <require
         permission="zope.ManageContent"
@@ -27,16 +32,13 @@
   <content class="zope.app.rdb.ZopeDatabaseAdapter">
 
     <implements
-        interface="zope.app.rdb.interfaces.IZopeDatabaseAdapter" />
-
-    <implements
         interface="zope.app.annotation.interfaces.IAttributeAnnotatable" />
 
     <implements
       interface="zope.app.utility.interfaces.ILocalUtility" />
 
     <require
-        permission="zope.Public"
+        permission="zope.app.rdb.Use"
         interface="zope.app.rdb.interfaces.IZopeDatabaseAdapter" />
 
   </content>

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/gadflyda.zcml
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/gadflyda.zcml	2004-08-12 21:02:48 UTC (rev 27087)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/gadflyda.zcml	2004-08-12 22:25:31 UTC (rev 27088)
@@ -4,8 +4,11 @@
     <factory
         title="Gadfly Database Adapter" />
     <require
-        permission="zope.Public"
+        permission="zope.app.rdb.Use"
         interface="zope.app.rdb.interfaces.IZopeDatabaseAdapter" />
+    <require
+        permission="zope.ManageServices"
+        interface="zope.app.rdb.interfaces.IZopeDatabaseAdapterManagement" />
   </content>
 
 </configure>

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/gadflymeta.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/gadflymeta.py	2004-08-12 21:02:48 UTC (rev 27087)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/gadflymeta.py	2004-08-12 22:25:31 UTC (rev 27088)
@@ -19,7 +19,6 @@
 from zope.interface import Interface
 
 from zope.app import zapi
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter
 from zope.app.rdb.gadflyda import setGadflyRoot 
 
 class IGadflyRoot(Interface):

Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/interfaces.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/interfaces.py	2004-08-12 21:02:48 UTC (rev 27087)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/rdb/interfaces.py	2004-08-12 22:25:31 UTC (rev 27088)
@@ -379,6 +379,15 @@
 
     This object is internal to the connection service."""
 
+    def isConnected():
+        """Check whether the Zope Connection is actually connected to the
+        database."""
+
+    def __call__():
+        """Return an IZopeConnection object"""
+
+class IZopeDatabaseAdapterManagement(Interface):
+
     def setDSN(dsn):
         """Set the DSN for the Adapter instance"""
 
@@ -406,14 +415,12 @@
     def disconnect():
         """Disconnect from the database."""
 
-    def isConnected():
-        """Check whether the Zope Connection is actually connected to the
-        database."""
+class IManageableZopeDatabaseAdapter(IZopeDatabaseAdapter,
+                                     IZopeDatabaseAdapterManagement):
+    """Database adapters with management functions
+    """
 
-    def __call__():
-        """Return an IZopeConnection object"""
 
-
 class IZopeConnection(IDBIConnection, IDBITypeInfoProvider):
 
     # An implementation of this object will be exposed to the



More information about the Zope3-Checkins mailing list