[Zope3-checkins] CVS: zopeproducts/informixDA - adapter.py:1.1 browser.py:1.1 configure.zcml:1.3 Adapter.py:NONE

Philipp von Weitershausen philikon@philikon.de
Wed, 30 Jul 2003 01:20:31 -0400


Update of /cvs-repository/zopeproducts/informixDA
In directory cvs.zope.org:/tmp/cvs-serv8321

Modified Files:
	configure.zcml 
Added Files:
	adapter.py browser.py 
Removed Files:
	Adapter.py 
Log Message:
Yet another database adapter converted.


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

$Id: adapter.py,v 1.1 2003/07/30 05:19:56 philikon Exp $
"""

import sapdbapi

from zope.app.rdb 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):
        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:
        return data()
    else:
        return data

converter_mapping = {
    "Char Binary": convertLongReader
    }


=== Added File zopeproducts/informixDA/browser.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.
#
##############################################################################
"""Informix database adapter.

$Id: browser.py,v 1.1 2003/07/30 05:19:56 philikon Exp $
"""

from zope.app.browser.rdb.rdb import AdapterAdd

class sapdbAddView(AdapterAdd):
      """Provide a user interface for adding a sapdb DA"""
      _adapter_factory_id = "sapdbDA"


=== zopeproducts/informixDA/configure.zcml 1.2 => 1.3 ===
--- zopeproducts/informixDA/configure.zcml:1.2	Fri Dec 13 14:51:26 2002
+++ zopeproducts/informixDA/configure.zcml	Wed Jul 30 01:19:56 2003
@@ -1,14 +1,39 @@
 <zopeConfigure
-    xmlns='http://namespaces.zope.org/zope'>
+   xmlns='http://namespaces.zope.org/zope'
+   xmlns:browser='http://namespaces.zope.org/browser'>
 
-    <content class=".Adapter.informixAdapter">
-        <implements 
-           interface="Zope.App.OFS.Annotation.IAttributeAnnotatable." />
-        <factory id="informixDA"
-                permission="Zope.Public" />
-        <require permission="Zope.Public"
-                interface="Zope.App.RDB.IZopeDatabaseAdapter." />
-    </content>
+  <content class=".adapter.sapdbAdapter">
 
- <include package=".browser" />
- </zopeConfigure>
+    <implements
+       interface="zope.app.interfaces.annotation.IAttributeAnnotatable"
+       />
+
+    <factory
+       id="informixDA"
+       permission="zope.Public"
+       />
+
+    <require permission="zope.Public"
+       interface="zope.app.interfaces.rdb.IZopeDatabaseAdapter"
+       />
+
+  </content>
+
+  <browser:view
+     name="zopeproducts.sapdbDA"
+     for="zope.app.interfaces.container.IAdding"
+     factory=".sapdbAddView."
+     permission="zope.ManageServices">
+
+    <browser:page name="+" attribute="add" />
+    <browser:page name="action.html" attribute="action" />
+
+  </browser:view>
+
+  <browser:menuItem menu="add_component"
+     for="zope.app.interfaces.container.IAdding"
+     title="SAPDB DA" action="zopeproducts.sapdbDA"
+     description="A SAPDB Database Adapter using the sapdbapi"
+     />
+
+</zopeConfigure>

=== Removed File zopeproducts/informixDA/Adapter.py ===