[Zope3-checkins] CVS: zopeproducts/sapdbda - 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:12:10 EDT 2003


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

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


=== Added File zopeproducts/sapdbda/TODO ===
    -   Check threadsafety
    -   Get newer module, compiled with current python API


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



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

$Id: adapter.py,v 1.1 2003/08/19 07:12:03 srichter Exp $
"""
import sapdbapi
import sapdb
from zope.app.rdb.ZopeDatabaseAdapter import \
    ZopeDatabaseAdapter, parseDSN, identity

class SAPdbAdapter(ZopeDatabaseAdapter):
    """A sapdb adapter for Zope3"""

    def _connection_factory(self):
        """Create a sapdb DBI connection based on the DSN"""
        conn_info = parseDSN(self.dsn)
        return sapdbapi.connect(conn_info['username'],
                                conn_info['password'],
                                conn_info['dbname'],
                                host=conn_info['host'])

    # IDBITypeInfo

    def getConverter(self, typechar):
        print "type", typechar
        return convertLongReader
        if converter_mapping.has_key(typechar):
            return converter_mapping[typechar]
        else:
            return identity


# Converters

def convertLongReader(data):
    # Converts a BLOB into a string. 
    # XXX Reads *all* data currently.
    if type(data) is sapdb.SapDB_LongReader:
        print data()
        return data()
    else:
        print "asdf", data
        if data:
            print unicode(data,"utf-8")
        return data

converter_mapping = {
    "Char Binary": convertLongReader }



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

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

  <browser:addform
      name="AddSAPdbDA"
      schema="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
      label="Add SAP Database Adapter"
      content_factory=".adapter.SAPdbAdapter"
      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="SAPdb DA" 
      description="An SAP Database Adapter"
      action="AddSAPdbDA" />

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

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

</configure>




More information about the Zope3-Checkins mailing list