[Zope-CVS] CVS: Products/Ape/lib/apelib/sql - interfaces.py:1.1 dbapi.py:1.3 sqlbase.py:1.6
Shane Hathaway
shane@zope.com
Sun, 18 May 2003 00:23:15 -0400
Update of /cvs-repository/Products/Ape/lib/apelib/sql
In directory cvs.zope.org:/tmp/cvs-serv24380/sql
Modified Files:
dbapi.py sqlbase.py
Added Files:
interfaces.py
Log Message:
Added ISQLConnection interface
=== Added File Products/Ape/lib/apelib/sql/interfaces.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.
#
##############################################################################
"""Interfaces for apelib.sql.
$Id: interfaces.py,v 1.1 2003/05/18 04:23:14 shane Exp $
"""
from Interface import Interface
class ISQLConnection (Interface):
"""Interface of SQL database connectors
"""
def getQuery(table_name, column_defs, operation):
"""Returns a query for invoking the specified operation.
The available operations depend on the query generator and the
database.
"""
def execute(query, fetch=0, cursor=None, **kw):
"""Executes a query.
If fetch is true, returns all of the rows from the query.
"""
def asBinary(data):
"""Converts a string to the database's binary type."""
=== Products/Ape/lib/apelib/sql/dbapi.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/sql/dbapi.py:1.2 Sun May 18 00:16:29 2003
+++ Products/Ape/lib/apelib/sql/dbapi.py Sun May 18 00:23:14 2003
@@ -21,6 +21,7 @@
from types import StringType
from apelib.core.interfaces import ITPCConnection
+from apelib.sql.interfaces import ISQLConnection
from querygen import makeQueryGenerator
DEBUG = os.environ.get('APE_DEBUG_SQL')
@@ -29,7 +30,7 @@
class DBAPIConnector:
- __implements__ = ITPCConnection
+ __implements__ = ITPCConnection, ISQLConnection
_final = 0
db = None
=== Products/Ape/lib/apelib/sql/sqlbase.py 1.5 => 1.6 ===
--- Products/Ape/lib/apelib/sql/sqlbase.py:1.5 Sun May 18 00:16:29 2003
+++ Products/Ape/lib/apelib/sql/sqlbase.py Sun May 18 00:23:14 2003
@@ -16,6 +16,9 @@
$Id$
"""
+from interfaces import ISQLConnection
+
+
class SQLGatewayBase:
"""SQL gateway base class"""
@@ -35,6 +38,7 @@
def setUp(self, event, clear_all=0):
conn = event.getConnection(self.conn_name)
+ assert ISQLConnection.isImplementedBy(conn)
try:
self.execute(event, 'check')
except conn.error: