[Zope-CVS] SVN: mysqldbda/trunk/ Sprinting with Claudia Albisetti.

Stephan Richter srichter at cosmos.phy.tufts.edu
Sat Oct 9 12:15:44 EDT 2004


Log message for revision 27856:
  Sprinting with Claudia Albisetti.
  
  Initial import of the updated mysqldbda.
  


Changed:
  A   mysqldbda/trunk/
  A   mysqldbda/trunk/__init__.py
  A   mysqldbda/trunk/adapter.py
  A   mysqldbda/trunk/configure.zcml
  A   mysqldbda/trunk/mysqldbda-configure.zcml


-=-
Added: mysqldbda/trunk/__init__.py
===================================================================
--- mysqldbda/trunk/__init__.py	2004-10-09 16:14:54 UTC (rev 27855)
+++ mysqldbda/trunk/__init__.py	2004-10-09 16:15:43 UTC (rev 27856)
@@ -0,0 +1 @@
+# Make directory a package

Added: mysqldbda/trunk/adapter.py
===================================================================
--- mysqldbda/trunk/adapter.py	2004-10-09 16:14:54 UTC (rev 27855)
+++ mysqldbda/trunk/adapter.py	2004-10-09 16:15:43 UTC (rev 27856)
@@ -0,0 +1,44 @@
+##############################################################################
+#
+# 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.3 2003/06/05 16:42:31 philikon dead $
+"""
+
+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)
+        print '*'*78
+        print conn_info
+        print '*'*78
+        return MySQLdb.Connect(db=conn_info['dbname'],
+                               host=conn_info['host'],
+                               user=conn_info['username'],
+                               passwd=conn_info['password'],
+                               port=int(conn_info['port'] or '3306'))
+                      

Added: mysqldbda/trunk/configure.zcml
===================================================================
--- mysqldbda/trunk/configure.zcml	2004-10-09 16:14:54 UTC (rev 27855)
+++ mysqldbda/trunk/configure.zcml	2004-10-09 16:15:43 UTC (rev 27856)
@@ -0,0 +1,47 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:browser="http://namespaces.zope.org/browser"
+    i18n_domain="mysqldbda">
+
+  <content class=".adapter.MySQLdbAdapter">
+    <factory id="zope.da.MySQLdbDA" />
+    <require
+        permission="zope.app.rdb.Use"
+        interface="zope.app.rdb.interfaces.IZopeDatabaseAdapter"
+        />
+    <require
+        permission="zope.ManageServices"
+        interface="zope.app.rdb.interfaces.IZopeDatabaseAdapterManagement"
+        />
+  </content>
+  
+  <browser:addform
+      name="AddMySQLdbDA"
+      schema="zope.app.rdb.interfaces.IManageableZopeDatabaseAdapter"
+      label="Add MySQL Database Adapter"
+      content_factory=".adapter.MySQLdbAdapter"
+      arguments="dsn"
+      fields="dsn"
+      permission="zope.ManageContent"
+      />
+
+  <!-- Menu entry for "add utility" menu -->
+  <browser:addMenuItem
+      class=".adapter.MySQLdbAdapter"
+      title="MySQL DA"
+      description="A MySQL Database Adapter"
+      permission="zope.ManageApplication"
+      view="AddMySQLdbDA"
+      />
+
+  <!-- Menu entry for "add connection" menu -->
+  <browser:menuItem
+      menu="add_connection"
+      for="zope.app.container.interfaces.IAdding"
+      title="MySQL DA"
+      description="A MySQL Database Adapter"
+      action="AddMySQLdbDA"
+      />
+
+</configure>
+

Added: mysqldbda/trunk/mysqldbda-configure.zcml
===================================================================
--- mysqldbda/trunk/mysqldbda-configure.zcml	2004-10-09 16:14:54 UTC (rev 27855)
+++ mysqldbda/trunk/mysqldbda-configure.zcml	2004-10-09 16:15:43 UTC (rev 27856)
@@ -0,0 +1 @@
+<include package="mysqldbda" />
\ No newline at end of file



More information about the Zope-CVS mailing list