[Zope-CVS] CVS: Packages/PsycopgDA - Adapter.py:1.1 __init__.py:1.1 configure.zcml:1.1
Stephan Richter
srichter@cbu.edu
Wed, 10 Jul 2002 22:01:49 -0400
Update of /cvs-repository/Packages/PsycopgDA
In directory cvs.zope.org:/tmp/cvs-serv9591
Added Files:
Adapter.py __init__.py configure.zcml
Log Message:
Initial implementation of Psycopg DA.
=== Added File Packages/PsycopgDA/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.
#
##############################################################################
"""
$Id: Adapter.py,v 1.1 2002/07/11 02:01:48 srichter Exp $
"""
import psycopg
from Persistence import Persistent
from Zope.App.RDB.ZopeDatabaseAdapter import ZopeDatabaseAdapter, parseDSN
from Zope.App.RDB.ZopeConnection import ZopeConnection
dsn2option_mapping = {'dbname': 'dbname',
'username': 'user',
'password': 'password'}
class PsycopgAdapter(ZopeDatabaseAdapter):
"""A PsycoPG adapter for Zope3"""
__implements__ = ZopeDatabaseAdapter.__implements__
def _connection_factory(self):
"""Create a Psycopg DBI connection based on the DSN"""
conn_info = parseDSN(self.dsn)
conn_list = []
for option in dsn2option_mapping:
if conn_info[option]:
conn_list.append('%s=%s' %(dsn2option_mapping[option],
conn_info[option]))
conn_str = ' '.join(conn_list)
return psycopg.connect(conn_str)
=== Added File Packages/PsycopgDA/__init__.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.
#
##############################################################################
"""XXX short summary goes here.
XXX longer description goes here.
$Id: __init__.py,v 1.1 2002/07/11 02:01:48 srichter Exp $
"""
=== Added File Packages/PsycopgDA/configure.zcml ===
<zopeConfigure
xmlns='http://namespaces.zope.org/zope'
>
<content class=".Adapter.PsycopgAdapter">
<factory id="PsycopgDA"
permission="Zope.Public" />
<require permission="Zope.Public"
interface="Zope.App.RDB.IZopeDatabaseAdapter." />
</content>
<include package=".Views" />
</zopeConfigure>