[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/ Move zope.app.rdb to zope.rdb, provide compatibility and convert a PlacelessSetup import.

Brian Sutherland jinty at web.de
Tue Apr 11 13:15:14 EDT 2006


Log message for revision 66857:
  Move zope.app.rdb to zope.rdb, provide compatibility and convert a PlacelessSetup import.

Changed:
  U   Zope3/branches/jim-adapter/src/zope/app/__init__.py
  D   Zope3/branches/jim-adapter/src/zope/app/rdb/
  A   Zope3/branches/jim-adapter/src/zope/rdb/
  D   Zope3/branches/jim-adapter/src/zope/rdb/__init__.py
  A   Zope3/branches/jim-adapter/src/zope/rdb/__init__.py
  D   Zope3/branches/jim-adapter/src/zope/rdb/gadflymeta.py
  A   Zope3/branches/jim-adapter/src/zope/rdb/gadflymeta.py
  D   Zope3/branches/jim-adapter/src/zope/rdb/interfaces.py
  A   Zope3/branches/jim-adapter/src/zope/rdb/interfaces.py
  D   Zope3/branches/jim-adapter/src/zope/rdb/metaconfigure.py
  A   Zope3/branches/jim-adapter/src/zope/rdb/metaconfigure.py
  D   Zope3/branches/jim-adapter/src/zope/rdb/tests/
  A   Zope3/branches/jim-adapter/src/zope/rdb/tests/
  U   Zope3/branches/jim-adapter/src/zope/rdb/tests/test_directives.py

-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/__init__.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/__init__.py	2006-04-11 15:19:30 UTC (rev 66856)
+++ Zope3/branches/jim-adapter/src/zope/app/__init__.py	2006-04-11 17:15:13 UTC (rev 66857)
@@ -26,6 +26,11 @@
     'zope.app.datetimeutils': 'zope.datetime',
     'zope.app.timezones': 'zope.datetime.timezones',
 
+    'zope.app.rdb': 'zope.rdb',
+    'zope.app.rdb.interfaces': 'zope.rdb.interfaces',
+    'zope.app.rdb.browser': 'zope.rdb.browser',
+    'zope.app.rdb.gadfly': 'zope.rdb.gadfly',
+    
     'zope.app.size': 'zope.size',
     'zope.app.size.interfaces': 'zope.size.interfaces',
 

Copied: Zope3/branches/jim-adapter/src/zope/rdb (from rev 66823, Zope3/branches/jim-adapter/src/zope/app/rdb)

Deleted: Zope3/branches/jim-adapter/src/zope/rdb/__init__.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/rdb/__init__.py	2006-04-10 22:21:23 UTC (rev 66823)
+++ Zope3/branches/jim-adapter/src/zope/rdb/__init__.py	2006-04-11 17:15:13 UTC (rev 66857)
@@ -1,507 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 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 RDBMS Transaction Integration.
-
-Provides a proxy for interaction between the zope transaction
-framework and the db-api connection. Databases which want to support
-sub transactions need to implement their own proxy.
-
-$Id$
-"""
-import time, random, thread
-from urllib import unquote_plus
-
-from persistent import Persistent
-
-import transaction
-from transaction.interfaces import IDataManager
-
-from zope.security.checker import NamesChecker
-
-from zope.interface import implements
-from zope.app.container.contained import Contained
-from zope.app.rdb.interfaces import DatabaseException, DatabaseAdapterError
-from zope.app.rdb.interfaces import IResultSet
-from zope.app.rdb.interfaces import IZopeConnection, IZopeCursor
-from zope.app.rdb.interfaces import IManageableZopeDatabaseAdapter
-from zope.thread import local
-
-
-DEFAULT_ENCODING = "utf-8"
-
-def sqlquote(x):
-    r"""
-    Escape data suitable for inclusion in generated ANSI SQL92 code for
-    cases where bound variables are not suitable.
-
-    >>> sqlquote("Hi")
-    "'Hi'"
-    >>> sqlquote("It's mine")
-    "'It''s mine'"
-    >>> sqlquote("\\'")
-    "'\\\\'''"
-    >>> sqlquote(u"\\'")
-    u"'\\\\'''"
-    >>> sqlquote(32)
-    32
-    >>> sqlquote(None)
-    'NULL'
-    """
-    if isinstance(x, (str, unicode)):
-        x = "'%s'" % x.replace('\\', '\\\\').replace("'", "''")
-    elif isinstance(x, (int, long, float)):
-        pass
-    elif x is None:
-        x = 'NULL'
-    else:
-        raise TypeError('do not know how to handle type %s' % type(x))
-    return x
-
-
-class ResultSet(list):
-    """Database Result Set.
-
-    Currently we don't do lazy instantation of rows.
-    """
-
-    implements(IResultSet)
-    __slots__ = ('columns',)
-
-    def __init__(self, columns, rows):
-        self.columns = tuple(columns)
-        row_class = RowClassFactory(columns)
-        super(ResultSet, self).__init__(map(row_class, rows))
-
-    __safe_for_unpickling__ = True
-
-    def __reduce__(self):
-        cols = self.columns
-        return (ResultSet,
-                (cols, [[getattr(row, col) for col in cols] for row in self])
-               )
-
-    def __cmp__(self, other):
-        if not isinstance(other, ResultSet):
-            return super(ResultSet, self).__cmp__(other)
-        c = cmp(self.columns, other.columns)
-        if c:
-            return c
-        for row, other_row in zip(self, other):
-            c = cmp(row, other_row)
-            if c:
-                return c
-        return cmp(len(self), len(other))
-
-
-class ZopeDatabaseAdapter(Persistent, Contained):
-
-    implements(IManageableZopeDatabaseAdapter)
-
-    # We need to store our connections in a thread local to ensure that
-    # different threads do not accidently use the same connection. This
-    # is important when instantiating database adapters using
-    # rdb:provideConnection as the same ZopeDatabaseAdapter instance will
-    # be used by all threads.
-    _connections = local()
-
-    def __init__(self, dsn):
-        self.setDSN(dsn)
-        self._unique_id = '%s.%s.%s' % (
-                time.time(), random.random(), thread.get_ident()
-                )
-
-    def _get_v_connection(self):
-        """We used to store the ZopeConnection in a volatile attribute.
-           However this was not always thread safe.
-        """
-        return getattr(ZopeDatabaseAdapter._connections, self._unique_id, None)
-
-    def _set_v_connection(self, value):
-        setattr(ZopeDatabaseAdapter._connections, self._unique_id, value)
-
-    _v_connection = property(_get_v_connection, _set_v_connection)
-
-    def _connection_factory(self):
-        """This method should be overwritten by all subclasses"""
-        conn_info = parseDSN(self.dsn)
-
-    def setDSN(self, dsn):
-        assert dsn.startswith('dbi://'), "The DSN has to start with 'dbi://'"
-        self.dsn = dsn
-
-    def getDSN(self):
-        return self.dsn
-
-    def connect(self):
-        if not self.isConnected():
-            try:
-                self._v_connection = ZopeConnection(
-                    self._connection_factory(), self)
-            except DatabaseException:
-                raise
-            # Note: I added the general Exception, since the DA can return
-            # implementation-specific errors. But we really want to catch all
-            # issues at this point, so that we can convert it to a
-            # DatabaseException.
-            except Exception, error:
-                raise DatabaseException(str(error))
-
-    def disconnect(self):
-        if self.isConnected():
-            self._v_connection.close()
-            self._v_connection = None
-
-    def isConnected(self):
-        return self._v_connection is not None
-
-    def __call__(self):
-        self.connect()
-        return self._v_connection
-
-    # Pessimistic defaults
-    paramstyle = 'pyformat'
-    threadsafety = 0
-    encoding = DEFAULT_ENCODING
-
-    def setEncoding(self, encoding):
-        # Check the encoding
-        "".decode(encoding)
-        self.encoding = encoding
-
-    def getEncoding(self):
-        return self.encoding
-
-    def getConverter(self, type):
-        'See IDBITypeInfo'
-        return identity
-
-def identity(x):
-    return x
-
-def parseDSN(dsn):
-    """Parses a database connection string.
-
-    We could have the following cases:
-
-       dbi://dbname
-       dbi://dbname;param1=value...
-       dbi://user/dbname
-       dbi://user:passwd/dbname
-       dbi://user:passwd/dbname;param1=value...
-       dbi://user@host/dbname
-       dbi://user:passwd@host/dbname
-       dbi://user:passwd@host:port/dbname
-       dbi://user:passwd@host:port/dbname;param1=value...
-
-    Any values that might contain characters special for URIs need to be
-    quoted as it would be returned by `urllib.quote_plus`.
-
-    Return value is a mapping with the following keys:
-
-       username     username (if given) or an empty string
-       password     password (if given) or an empty string
-       host         host (if given) or an empty string
-       port         port (if given) or an empty string
-       dbname       database name
-       parameters   a mapping of additional parameters to their values
-    """
-    if not isinstance(dsn, (str, unicode)):
-        raise ValueError('The dsn is not a string. It is a %r' % type(dsn))
-    if not dsn.startswith('dbi://'):
-        raise ValueError('Invalid DSN; must start with "dbi://": %r' % dsn)
-
-    result = {}
-
-    dsn = dsn[6:]
-    # Get parameters (dict) from DSN
-    raw_params = dsn.split(';')
-    dsn = raw_params[0]
-    raw_params = raw_params[1:]
-
-    parameters = [param.split('=') for param in raw_params]
-    parameters = dict([(unquote_plus(key), unquote_plus(value))
-                       for key, value in parameters])
-
-    result['parameters'] = parameters
-
-    # Get the dbname from the DSN
-    if dsn.find('/') > 0:
-        dsn, dbname = dsn.split('/')
-    else:
-        dbname = dsn
-        dsn = ''
-
-    result['dbname'] = unquote_plus(dbname)
-
-    # Get host and port from DSN
-    if dsn and dsn.find('@') > 0:
-        dsn, host_port = dsn.split('@')
-        if host_port.find(':') > 0:
-            host, port = host_port.split(':')
-        else:
-            host, port = host_port, ''
-    else:
-        host, port = '', ''
-
-    result['host'] = host
-    result['port'] = port
-
-    # Get username and password from DSN
-    if dsn:
-        if dsn.find(':') > 0:
-            username, password = dsn.split(':', 1)
-        else:
-             username, password = dsn, ''
-    else:
-        username, password = '', ''
-
-    result['username'] = unquote_plus(username)
-    result['password'] = unquote_plus(password)
-
-    return result
-
-
-class ZopeCursor(object):
-    implements(IZopeCursor)
-
-    def __init__(self, cursor, connection):
-        self.cursor = cursor
-        self.connection = connection
-
-    def execute(self, operation, parameters=None):
-        """Executes an operation, registering the underlying
-        connection with the transaction system.  """
-        operation, parameters = self._prepareOperation(operation, parameters)
-        self.connection.registerForTxn()
-        if parameters is None:
-            return self.cursor.execute(operation)
-        return self.cursor.execute(operation, parameters)
-
-    def executemany(self, operation, parameters):
-        """Executes an operation, registering the underlying
-        connection with the transaction system.  """
-        operation, parameters = self._prepareOperation(operation, parameters)
-        # If executemany() is not defined pass parameters
-        # to execute() as defined by DB API v.1
-        method = getattr(self.cursor, "executemany", self.cursor.execute)
-        self.connection.registerForTxn()
-        return method(operation, parameters)
-
-    def _prepareOperation(self, operation, parameters):
-        encoding = self.connection.getTypeInfo().getEncoding()
-        if isinstance(operation, unicode):
-            operation = operation.encode(encoding)
-        parameters = self._prepareParameters(parameters, encoding)
-        return operation, parameters
-
-    def _prepareParameters(self, parameters, encoding):
-        if isinstance(parameters, list):
-            for i, v in enumerate(parameters):
-                if isinstance(v, unicode):
-                    parameters[i] = v.encode(encoding)
-                else:
-                    parameters[i] = self._prepareParameters(v, encoding)
-        elif isinstance(parameters, tuple):
-            parameters = list(parameters)
-            for i, v in enumerate(parameters):
-                if isinstance(v, unicode):
-                    parameters[i] = v.encode(encoding)
-            parameters = tuple(parameters)
-        elif isinstance(parameters, dict):
-            for k, v in parameters.items():
-                if isinstance(v, unicode):
-                    parameters[k] = v.encode(encoding)
-        return parameters
-
-    def __getattr__(self, key):
-        return getattr(self.cursor, key)
-
-    def fetchone(self):
-        results = self.cursor.fetchone()
-        if results is None:
-            return None
-        return self._convertTypes([results])[0]
-
-    def fetchmany(self, *args, **kw):
-        results = self.cursor.fetchmany(*args, **kw)
-        return self._convertTypes(results)
-
-    def fetchall(self):
-        results = self.cursor.fetchall()
-        return self._convertTypes(results)
-
-    def _convertTypes(self, results):
-        "Perform type conversion on query results"
-        getConverter = self.connection.getTypeInfo().getConverter
-        converters = [getConverter(col_info[1])
-                      for col_info in self.cursor.description]
-## A possible optimization -- need benchmarks to check if it is worth it
-##      if [x for x in converters if x is not ZopeDatabaseAdapter.identity]:
-##          return results  # optimize away
-
-        def convertRow(row):
-            return map(lambda converter, value: converter(value),
-                       converters, row)
-
-        return map(convertRow, results)
-
-class ZopeConnection(object):
-
-    implements(IZopeConnection)
-
-    def __init__(self, conn, typeinfo):
-        self.conn = conn
-        self._txn_registered = False
-        self._type_info = typeinfo
-
-    def __getattr__(self, key):
-        # The IDBIConnection interface is hereby implemented
-        return getattr(self.conn, key)
-
-    def cursor(self):
-        'See IZopeConnection'
-        return ZopeCursor(self.conn.cursor(), self)
-
-    def registerForTxn(self):
-        'See IZopeConnection'
-        if not self._txn_registered:
-            tm = ZopeDBTransactionManager(self)
-            transaction.get().join(tm)
-            self._txn_registered = True
-
-    def commit(self):
-        'See IDBIConnection'
-        self._txn_registered = False
-        self.conn.commit()
-
-    def rollback(self):
-        'See IDBIConnection'
-        self._txn_registered = False
-        self.conn.rollback()
-
-    def getTypeInfo(self):
-        'See IDBITypeInfoProvider'
-        return self._type_info
-
-
-def queryForResults(conn, query):
-    """Convenience function to quickly execute a query."""
-
-    cursor = conn.cursor()
-
-    try:
-        cursor.execute(query)
-    except Exception, error:
-        # Just catch the exception, so that we can convert it to a database
-        # exception.
-        raise DatabaseException(str(error))
-
-    if cursor.description is not None:
-        columns = [c[0] for c in cursor.description]
-        results = cursor.fetchall()
-    else:
-        # Handle the case that the query was not a SELECT
-        columns = []
-        results = []
-
-    return ResultSet(columns, results)
-
-
-class ZopeDBTransactionManager(object):
-
-    implements(IDataManager)
-
-    def __init__(self, dbconn):
-        self._dbconn = dbconn
-        self.transaction_manager = transaction.manager
-
-    def prepare(self, txn):
-        pass
-
-    def tpc_begin(self, txn):
-        pass
-
-    def tpc_vote(self, txn):
-        pass
-
-    def tpc_finish(self, txn):
-        pass
-
-    def tpc_abort(self, txn):
-        pass
-
-    def abort(self, txn):
-        self._dbconn.rollback()
-
-    def commit(self, txn):
-        self._dbconn.commit()
-
-    def sortKey(self):
-        """
-        ZODB uses a global sort order to prevent deadlock when it commits
-        transactions involving multiple resource managers.  The resource
-        manager must define a sortKey() method that provides a global ordering
-        for resource managers.
-
-        (excerpt from transaction/notes.txt)
-        """
-        return 'rdb' + str(id(self))
-
-class Row(object):
-    """Represents a row in a ResultSet"""
-
-    def __init__(self, data):
-        for k, v in zip(self.__slots__, data):
-            setattr(self, k, v)
-
-    def __str__(self):
-        return "row class %s" % str(self.__slots__)
-
-    def __cmp__(self, other):
-        if not isinstance(other, Row):
-            return super(Row, self).__cmp__(other)
-        c = cmp(self.__slots__, other.__slots__)
-        if c:
-            return c
-        for column in self.__slots__:
-            c = cmp(getattr(self, column), getattr(other, column))
-            if c:
-                return c
-        return 0
-
-class InstanceOnlyDescriptor(object):
-    __marker = object()
-    def __init__(self, value=__marker):
-        if value is not self.__marker:
-            self.value = value
-
-    def __get__(self, inst, cls=None):
-        if inst is None:
-            raise AttributeError
-        return self.value
-
-    def __set__(self, inst, value):
-        self.value = value
-
-    def __delete__(self, inst):
-        del self.value
-
-def RowClassFactory(columns):
-    """Creates a Row object"""
-    klass_namespace = {}
-    klass_namespace['__Security_checker__'] = InstanceOnlyDescriptor(
-        NamesChecker(columns))
-    klass_namespace['__slots__'] = tuple(columns)
-
-    return type('GeneratedRowClass', (Row,), klass_namespace)

Copied: Zope3/branches/jim-adapter/src/zope/rdb/__init__.py (from rev 66856, Zope3/branches/jim-adapter/src/zope/app/rdb/__init__.py)

Deleted: Zope3/branches/jim-adapter/src/zope/rdb/gadflymeta.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/rdb/gadflymeta.py	2006-04-10 22:21:23 UTC (rev 66823)
+++ Zope3/branches/jim-adapter/src/zope/rdb/gadflymeta.py	2006-04-11 17:15:13 UTC (rev 66857)
@@ -1,38 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""'gadflyRoot' Directive Handler
-
-$Id: metaconfigure.py 25177 2004-06-02 13:17:31Z jim $
-"""
-from zope.configuration.fields import Path
-from zope.interface import Interface
-
-from zope.app import zapi
-from zope.app.rdb.gadflyda import setGadflyRoot 
-
-class IGadflyRoot(Interface):
-    """This directive creates a globale connection to an RDBMS."""
-
-    path = Path(
-        title=u"Path of Gadfly Root",
-        description=u"Specifies the path of the gadfly root relative to the"
-                    u"packge.",
-        required=True)
-
-
-def gadflyRootHandler(_context, path):
-    _context.action(
-            discriminator = ('gadflyRoot',),
-            callable = setGadflyRoot,
-            args = (path,) )

Copied: Zope3/branches/jim-adapter/src/zope/rdb/gadflymeta.py (from rev 66856, Zope3/branches/jim-adapter/src/zope/app/rdb/gadflymeta.py)

Deleted: Zope3/branches/jim-adapter/src/zope/rdb/interfaces.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/rdb/interfaces.py	2006-04-10 22:21:23 UTC (rev 66823)
+++ Zope3/branches/jim-adapter/src/zope/rdb/interfaces.py	2006-04-11 17:15:13 UTC (rev 66857)
@@ -1,333 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 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.
-#
-##############################################################################
-"""Relational Database Adapter interfaces.
-
-$Id$
-"""
-from zope.interface import Interface
-from zope.interface import Attribute
-from zope.schema import TextLine
-from zope.app.i18n import ZopeMessageFactory as _
-
-
-class IDBITypeInfoProvider(Interface):
-    """This object can get the Type Info for a particular DBI
-    implementation."""
-
-    def getTypeInfo():
-        """Return an IDBITypeInfo object."""
-
-class IDBITypeInfo(Interface):
-    """Database adapter specific information"""
-
-    paramstyle = Attribute("""
-        String constant stating the type of parameter marker formatting
-        expected by the interface. Possible values are [2]:
-
-       'qmark' = Question mark style, e.g. '...WHERE name=?'
-       'numeric' = Numeric, positional style, e.g. '...WHERE name=:1'
-       'named' = Named style, e.g. '...WHERE name=:name'
-       'format' = ANSI C printf format codes, e.g. '...WHERE name=%s'
-       'pyformat' = Python extended format codes, e.g. '...WHERE name=%(name)s'
-       """)
-
-    threadsafety = Attribute("""
-        Integer constant stating the level of thread safety the interface
-        supports. Possible values are:
-
-            0 = Threads may not share the module.
-            1 = Threads may share the module, but not connections.
-            2 = Threads may share the module and connections.
-            3 = Threads may share the module, connections and cursors.
-
-        Sharing in the above context means that two threads may use a resource
-        without wrapping it using a mutex semaphore to implement resource
-        locking. Note that you cannot always make external resources thread
-        safe by managing access using a mutex: the resource may rely on global
-        variables or other external sources that are beyond your control.
-        """)
-
-    encoding = TextLine(
-        title=_("Database encoding"),
-        description=_("Encoding of the database content"),
-        default=u"utf-8",
-        required=False
-        )
-
-    def getEncoding():
-        """Get the database encoding."""
-
-    def setEncoding(encoding):
-        """Set the database encoding."""
-
-    def getConverter(type):
-        """Return a converter function for field type matching key"""
-
-class IResultSet(Interface):
-    """Holds results, and allows iteration."""
-
-    columns = Attribute("""A list of the column names of the returned result
-                           set.""")
-
-    def __getitem__(index):
-        """Return a brain row for index."""
-
-
-class DatabaseException(Exception):
-    """Generic Database Error"""
-
-    def __init__(self, message):
-        self.message = message
-
-    def __str__(self):
-        return self.message
-
-class DatabaseAdapterError(DatabaseException):
-    pass
-
-arraysize = 1 # default constant, symbolic
-
-class IDBICursor(Interface):
-    """DB API ICursor interface"""
-
-    description = Attribute("""This read-only attribute is a sequence of
-        7-item sequences. Each of these sequences contains information
-        describing one result column: (name, type_code, display_size,
-        internal_size, precision, scale, null_ok). This attribute will be None
-        for operations that do not return rows or if the cursor has not had an
-        operation invoked via the executeZZZ() method yet.
-
-        The type_code can be interpreted by comparing it to the Type Objects
-        specified in the section below. """)
-
-    arraysize = Attribute("""This read/write attribute specifies the number of
-        rows to fetch at a time with fetchmany(). It defaults to 1 meaning to
-        fetch a single row at a time.
-
-        Implementations must observe this value with respect to the
-        fetchmany() method, but are free to interact with the database a
-        single row at a time. It may also be used in the implementation of
-        executemany().
-        """)
-
-    def close():
-        """Close the cursor now (rather than whenever __del__ is called).  The
-        cursor will be unusable from this point forward; an Error (or
-        subclass) exception will be raised if any operation is attempted with
-        the cursor.
-        """
-
-    def execute(operation, parameters=None):
-        """Prepare and execute a database operation (query or
-        command). Parameters may be provided as sequence or mapping and will
-        be bound to variables in the operation. Variables are specified in a
-        database-specific notation (see the module's paramstyle attribute for
-        details). [5]
-
-        A reference to the operation will be retained by the cursor. If the
-        same operation object is passed in again, then the cursor can optimize
-        its behavior. This is most effective for algorithms where the same
-        operation is used, but different parameters are bound to it (many
-        times).
-
-        For maximum efficiency when reusing an operation, it is best to use
-        the setinputsizes() method to specify the parameter types and sizes
-        ahead of time. It is legal for a parameter to not match the predefined
-        information; the implementation should compensate, possibly with a
-        loss of efficiency.
-
-        The parameters may also be specified as list of tuples to e.g. insert
-        multiple rows in a single operation, but this kind of usage is
-        depreciated: executemany() should be used instead.
-
-        Return values are not defined.
-        """
-
-    def executemany(operation, seq_of_parameters):
-        """Prepare a database operation (query or command) and then execute it
-        against all parameter sequences or mappings found in the sequence
-        seq_of_parameters.
-
-        Modules are free to implement this method using multiple calls to the
-        execute() method or by using array operations to have the database
-        process the sequence as a whole in one call.
-
-        The same comments as for execute() also apply accordingly to this
-        method.
-
-        Return values are not defined.
-        """
-
-    def fetchone():
-        """Fetch the next row of a query result set, returning a single
-        sequence, or None when no more data is available. [6]
-
-        An Error (or subclass) exception is raised if the previous call to
-        executeZZZ() did not produce any result set or no call was issued yet.
-        """
-
-    def fetchmany(size=arraysize):
-        """Fetch the next set of rows of a query result, returning a sequence
-        of sequences (e.g. a list of tuples). An empty sequence is returned
-        when no more rows are available.
-
-        The number of rows to fetch per call is specified by the parameter. If
-        it is not given, the cursor's arraysize determines the number of rows
-        to be fetched. The method should try to fetch as many rows as
-        indicated by the size parameter. If this is not possible due to the
-        specified number of rows not being available, fewer rows may be
-        returned.
-
-        An Error (or subclass) exception is raised if the previous call to
-        executeZZZ() did not produce any result set or no call was issued yet.
-
-        Note there are performance considerations involved with the size
-        parameter. For optimal performance, it is usually best to use the
-        arraysize attribute. If the size parameter is used, then it is best
-        for it to retain the same value from one fetchmany() call to the next.
-        """
-
-    def fetchall():
-        """Fetch all (remaining) rows of a query result, returning them as a
-        sequence of sequences (e.g. a list of tuples). Note that the cursor's
-        arraysize attribute can affect the performance of this operation.
-
-        An Error (or subclass) exception is raised if the previous call to
-        executeZZZ() did not produce any result set or no call was issued yet.
-        """
-
-class IDBIConnection(Interface):
-    """A DB-API based Interface """
-
-    def cursor():
-        """Return a new IDBICursor Object using the connection.
-
-        If the database does not provide a direct cursor concept, the module
-        will have to emulate cursors using other means to the extent needed by
-        this specification.  """
-
-    def commit():
-        """Commit any pending transaction to the database. Note that if the
-        database supports an auto-commit feature, this must be initially off.
-        An interface method may be provided to turn it back on.
-
-        Database modules that do not support transactions should implement
-        this method with void functionality.
-        """
-
-    def rollback():
-        """In case a database does provide transactions this method causes the
-        database to roll back to the start of any pending transaction. Closing
-        a connection without committing the changes first will cause an
-        implicit rollback to be performed.  """
-
-    def close():
-        """Close the connection now (rather than whenever __del__ is
-        called). The connection will be unusable from this point forward; an
-        Error (or subclass) exception will be raised if any operation is
-        attempted with the connection. The same applies to all cursor objects
-        trying to use the connection.  """
-
-class ISQLCommand(Interface):
-    """Static SQL commands."""
-
-    connectionName = Attribute("""The name of the database connection
-    to use in getConnection """)
-
-    def getConnection():
-        """Get the database connection."""
-
-    def __call__():
-        """Execute an sql query and return a result object if appropriate"""
-
-class IZopeDatabaseAdapter(IDBITypeInfo):
-    """Interface for persistent object that returns
-    volatile IZopeConnections."""
-
-    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"""
-
-    def getDSN():
-        """Get the DSN of the Adapter instance"""
-
-    dsn = TextLine(
-        title=_("DSN"),
-        description=_(
-        "Specify the DSN (Data Source Name) of the database. "
-        "Examples include:\n"
-        "\n"
-        "dbi://dbname\n"
-        "dbi://dbname;param1=value...\n"
-        "dbi://user:passwd/dbname\n"
-        "dbi://user:passwd/dbname;param1=value...\n"
-        "dbi://user:passwd@host:port/dbname\n"
-        "dbi://user:passwd@host:port/dbname;param1=value...\n"
-        "\n"
-        "All values should be properly URL-encoded."),
-        default=u"dbi://dbname",
-        required=True)
-
-    def connect():
-        """Connect to the specified database."""
-
-    def disconnect():
-        """Disconnect from the database."""
-
-class IManageableZopeDatabaseAdapter(IZopeDatabaseAdapter,
-                                     IZopeDatabaseAdapterManagement):
-    """Database adapters with management functions
-    """
-
-class IZopeConnection(IDBIConnection, IDBITypeInfoProvider):
-
-    # An implementation of this object will be exposed to the
-    # user. Therefore the Zope connection represents a connection in
-    # the Zope sense, meaning that the object might not be actually
-    # connected to a real relational database.
-
-    def cursor():
-        """Return an IZopeCursor object."""
-
-    def registerForTxn():
-        """Join the current transaction.
-
-        This method should only be inovoked by the Zope/DB transaction
-        manager.
-        """
-
-class IZopeCursor(IDBICursor):
-    """An IDBICursor that integrates with Zope's transactions"""
-
-    def execute(operation, parameters=None):
-        """Executes an operation, registering the underlying connection with
-        the transaction system.
-
-        See IDBICursor for more detailed execute information.
-        """
-
-    def executemany(operation, seq_of_parameters):
-        """Executes an operation, registering the underlying connection with
-        the transaction system.
-
-        See IDBICursor for more detailed executemany information.
-        """

Copied: Zope3/branches/jim-adapter/src/zope/rdb/interfaces.py (from rev 66856, Zope3/branches/jim-adapter/src/zope/app/rdb/interfaces.py)

Deleted: Zope3/branches/jim-adapter/src/zope/rdb/metaconfigure.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/rdb/metaconfigure.py	2006-04-10 22:21:23 UTC (rev 66823)
+++ Zope3/branches/jim-adapter/src/zope/rdb/metaconfigure.py	2006-04-11 17:15:13 UTC (rev 66857)
@@ -1,39 +0,0 @@
-##############################################################################
-#
-# 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.
-#
-##############################################################################
-"""'rdb' ZCML Namespace Directive Handler
-
-$Id$
-"""
-from zope.app import zapi
-from zope.app.rdb.interfaces import IZopeDatabaseAdapter
-
-
-def connectionhandler(_context, name, component, dsn):
-    connection = component(dsn)
-    _context.action(
-            discriminator = ('provideConnection', name),
-            callable = provideConnection,
-            args = (name, connection) )
-    
-def provideConnection(name, connection):
-    """ Registers a database connection
-    
-    Uses the global site manager for registering the connection
-    """
-    gsm = zapi.getGlobalSiteManager()
-    gsm.registerUtility(connection, IZopeDatabaseAdapter, name)
-
-
-    
-

Copied: Zope3/branches/jim-adapter/src/zope/rdb/metaconfigure.py (from rev 66856, Zope3/branches/jim-adapter/src/zope/app/rdb/metaconfigure.py)

Copied: Zope3/branches/jim-adapter/src/zope/rdb/tests (from rev 66856, Zope3/branches/jim-adapter/src/zope/app/rdb/tests)

Modified: Zope3/branches/jim-adapter/src/zope/rdb/tests/test_directives.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/rdb/tests/test_directives.py	2006-04-11 15:19:30 UTC (rev 66856)
+++ Zope3/branches/jim-adapter/src/zope/rdb/tests/test_directives.py	2006-04-11 17:15:13 UTC (rev 66857)
@@ -16,7 +16,7 @@
 $Id$
 """
 import unittest
-from zope.app.testing.placelesssetup import PlacelessSetup
+from zope.component.testing import PlacelessSetup
 from zope.component import getUtilitiesFor, queryUtility
 from zope.configuration import xmlconfig
 from zope.app.rdb.interfaces import IZopeDatabaseAdapter



More information about the Zope3-Checkins mailing list