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

Philipp von Weitershausen philikon@philikon.de
Thu, 5 Jun 2003 12:42:33 -0400


Update of /cvs-repository/zopeproducts/mysqldbda
In directory cvs.zope.org:/tmp/cvs-serv27616/mysqldbda

Added Files:
	__init__.py adapter.py browser.py configure.zcml 
Log Message:
Ported the MySQL-db database adapter over using the namegheddon naming
scheme.


=== Added File zopeproducts/mysqldbda/__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.
#
##############################################################################
"""MySQL database adapter

$Id: __init__.py,v 1.1 2003/06/05 16:42:32 philikon Exp $
"""


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

$Id: adapter.py,v 1.1 2003/06/05 16:42:32 philikon Exp $
"""

import MySQLdb

from zope.app.rdb import ZopeDatabaseAdapter, parseDSN

dsn2option_mapping = {'dbname':'dbname',
                      'port':'port',
                      'host':'host',
                      'username':'user',
                      'password':'passwd'}

class MySQLdbAdapter(ZopeDatabaseAdapter):
    """A MySQLdb adapter for Zope3"""

    def _connection_factory(self):
        """Create a MySQLdb DBI connection based on the DSN"""

        conn_info = parseDSN(self.dsn)
        return MySQLdb.Connect(db=conn_info['dbname'],
                             host=conn_info['host'],
                             user=conn_info['username'],
                             passwd=conn_info['password'],
                             port=int(conn_info['port']))


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

Browser add view.

$Id: browser.py,v 1.1 2003/06/05 16:42:32 philikon Exp $
"""

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

class MySQLdbAddView(AdapterAdd):
      """Provide a user interface for adding a MySQLdb DA"""
      _adapter_factory_id = "mysqldbda"


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

  <content class=".adapter.MySQLdbAdapter">
    <factory id="mysqldbda" permission="zope.Public" />
    <require permission="zope.Public"
      interface="zope.app.interfaces.rdb.IZopeDatabaseAdapter." />
    <implements interface="zope.app.interfaces.annotation.IAttributeAnnotatable." />
  </content>

  <browser:view
    name="zopeproducts.mysqldbda"
    for="zope.app.interfaces.container.IAdding."
    class="zopeproducts.mysqldbda.browser.MySQLdbAddView"
    permission="zope.Public">

    <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="MySQLdb DA" action="zopeproducts.mysqldbda"
    description="A MySQL Database Adapter using the mysql-db driver"/>

</zopeConfigure>