[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/content - sql.py:1.6

Stephan Richter srichter@cosmos.phy.tufts.edu
Wed, 11 Jun 2003 09:48:29 -0400


Update of /cvs-repository/Zope3/src/zope/app/interfaces/content
In directory cvs.zope.org:/tmp/cvs-serv23479/interfaces/content

Modified Files:
	sql.py 
Log Message:
Fixed SQLScript:

- Removed doubled 'Cache' menu entry.

- I had to context-wrap connectionName (using ContextProperty), since
  ContextMethod(setConnectionName) did not work anymore.

- Caching also did not work correctly; in the __call__() method of SQLScript
  it used a lit '[]' as the marker for the default return object; for some
  reason this did not work. When I replaced the list with object(),
  everything worked just fine.

- Removed many bare excepts and therefore XXX comments

- Cleaned up the ISQLScript interface to remove old cruft from the time I did
  not feel comfortable with properties

- Fixed bug where it would not allow you to edit an SQL script unless a 'SQL
  Connections Service' was registered. 

- In the 'rdb' package, if we experience an exception during connect, we want
  to convert this exception to a DatabaseException, so that the higher-level
  machinery can catch it. Note that I had to leave the exception blank, since
  DBI implementations have their own Exception hierarchy.


=== Zope3/src/zope/app/interfaces/content/sql.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/interfaces/content/sql.py:1.5	Tue May 27 10:18:19 2003
+++ Zope3/src/zope/app/interfaces/content/sql.py	Wed Jun 11 09:47:58 2003
@@ -17,19 +17,25 @@
 import zope.schema
 
 from zope.app.interfaces.rdb import ISQLCommand
-from zope.component import getService
+from zope.component import getService, ComponentLookupError
 from zope.context import ContextProperty
 from zope.app.i18n import ZopeMessageIDFactory as _
 
+class MissingInput(Exception):
+    pass
 
 class SQLConnectionName(zope.schema.TextLine):
     """SQL Connection Name"""
 
     def __allowed(self):
         """Note that this method works only if the Field is context wrapped."""
-        connection_service = getService(self.context, "SQLDatabaseConnections")
-        connections = connection_service.getAvailableConnections()
-        return connections
+        try:
+            connection_service = getService(self.context,
+                                            "SQLDatabaseConnections")
+        except ComponentLookupError:
+            return []
+        
+        return connection_service.getAvailableConnections()
 
     allowed_values = ContextProperty(__allowed)
 
@@ -52,28 +58,8 @@
         description=_(u"The source of the page template."),
         required=True)
 
-    def setArguments(arguments):
-        """Processes the arguments (which could be a dict, string or whatever)
-        to arguments as they are needed for the rendering process."""
-
     def getArguments():
-        """Get the arguments. A method is preferred here, since some argument
-        evaluation might be done."""
-
-    def getArgumentsString():
-        """This method returns the arguments string."""
-
-    def setSource(source):
-        """Save the source of the page template."""
-
-    def getSource():
-        """Get the source of the page template."""
+        """Returns a set of arguments. Note that this is not a string!"""
 
     def getTemplate():
         """Get the SQL DTML Template object."""
-
-    def setConnectionName(name):
-        """Save the connection name for this SQL Script."""
-
-    def getConnectionName():
-        """Get the connection name for this SQL Script."""