[Zope3-checkins] CVS: zopeproducts/odbcda - TODO:1.1 __init__.py:1.1 adapter.py:1.1 configure.zcml:1.1

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


Update of /cvs-repository/zopeproducts/odbcda
In directory cvs.zope.org:/tmp/cvs-serv17486/odbcda

Added Files:
	TODO __init__.py adapter.py configure.zcml 
Log Message:
Updated all Database Adaptors.


=== Added File zopeproducts/odbcda/TODO ===
    -   Know the threadsafety level
    -   Test on a real database
    -   Typeconversion specialities?


=== Added File zopeproducts/odbcda/__init__.py ===
# make this a python package



=== Added File zopeproducts/odbcda/adapter.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.
#
##############################################################################
"""ODBC database adapter.

$Id: adapter.py,v 1.1 2003/08/19 07:11:43 srichter Exp $
"""
import mxODBC
from zope.app.rdb.ZopeDatabaseAdapter import ZopeDatabaseAdapter, parseDSN

class ODBCAdapter(ZopeDatabaseAdapter):
    """An ODBC adapter for Zope3"""

    __implements__ = ZopeDatabaseAdapter.__implements__

    def _connection_factory(self):
        """Create an ODBC connection based on the DSN"""
        conn_info = parseDSN(self.dsn)
        return mxODBC.connect(user=conn_info['username'],
                            password=conn_info['password'],
                            database=conn_info['dbname'],
                            host=conn_info['host'])


=== Added File zopeproducts/odbcda/configure.zcml ===
<configure
   xmlns="http://namespaces.zope.org/zope"
   xmlns:browser="http://namespaces.zope.org/browser"
   i18n_domain="odbc">

  <content class=".adapter.ODBCAdapter">
    <factory
        id="zope.da.ODBCDA"
        permission="zope.Public"/>
    <require 
        permission="zope.Public"
        interface="zope.app.interfaces.rdb.IZopeDatabaseAdapter"/>
  </content>

  <browser:addform
      name="AddODBCDA"
      schema="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
      label="Add ODBC Database Adapter"
      content_factory=".adapter.ODBCAdapter"
      arguments="dsn"
      fields="dsn"
      permission="zope.ManageContent" />

  <!-- Menu entry for "add component" menu -->
  <browser:menuItem 
      menu="add_component"
      for="zope.app.interfaces.container.IAdding"
      title="ODBC DA" 
      description="An ODBC Database Adapter"
      action="AddODBCDA" />

  <!-- Menu entry for "add utility" menu -->
  <browser:menuItem
      menu="add_utility"
      for="zope.app.interfaces.container.IAdding"
      title="ODBC DA" 
      description="An ODBC Database Adapter"
      action="AddODBCDA" />

  <!-- Menu entry for "add connection" menu -->
  <browser:menuItem
      menu="add_connection"
      for="zope.app.interfaces.container.IAdding"
      title="ODBC DA" 
      description="An ODBC Database Adapter"
      action="AddODBCDA" />

</configure>




More information about the Zope3-Checkins mailing list