[Zope-CVS] CVS: Products3/PsycopgDA - Adapter.py:1.1 __init__.py:1.1 configure.zcml:1.1
Viktorija Zaksiene
ryzaja@codeworks.lt
Wed, 13 Nov 2002 05:13:23 -0500
Update of /cvs-repository/Products3/PsycopgDA
In directory cvs.zope.org:/tmp/cvs-serv10085
Added Files:
Adapter.py __init__.py configure.zcml
Log Message:
Moved Zope 3 PostgreSQL database adapter to Products3 from Products
=== Added File Products3/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.
#
##############################################################################
"""PostgreSQL Database Adapter for Zope 3
$Id: Adapter.py,v 1.1 2002/11/13 10:13:22 ryzaja 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 Products3/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.
#
##############################################################################
"""PostgreSQL Database Adapter for Zope 3
$Id: __init__.py,v 1.1 2002/11/13 10:13:22 ryzaja Exp $
"""
=== Added File Products3/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>