[Checkins] SVN: mysqldbda/trunk/ package eggification
Nikolay Kim
fafhrd at datacom.kz
Wed Feb 20 06:20:05 EST 2008
Log message for revision 84072:
package eggification
Changed:
A mysqldbda/trunk/CHANGES.txt
D mysqldbda/trunk/DEPENDENCIES.cfg
D mysqldbda/trunk/PACKAGE.cfg
D mysqldbda/trunk/PUBLICATION.cfg
D mysqldbda/trunk/README.txt
D mysqldbda/trunk/SETUP.cfg
D mysqldbda/trunk/__init__.py
D mysqldbda/trunk/adapter.py
A mysqldbda/trunk/bootstrap.py
A mysqldbda/trunk/buildout.cfg
D mysqldbda/trunk/configure.zcml
D mysqldbda/trunk/mysqldbda-configure.zcml
A mysqldbda/trunk/setup.py
A mysqldbda/trunk/src/
A mysqldbda/trunk/src/mysqldbda/
A mysqldbda/trunk/src/mysqldbda/DEPENDENCIES.cfg
A mysqldbda/trunk/src/mysqldbda/PACKAGE.cfg
A mysqldbda/trunk/src/mysqldbda/PUBLICATION.cfg
A mysqldbda/trunk/src/mysqldbda/README.txt
A mysqldbda/trunk/src/mysqldbda/SETUP.cfg
A mysqldbda/trunk/src/mysqldbda/__init__.py
A mysqldbda/trunk/src/mysqldbda/adapter.py
A mysqldbda/trunk/src/mysqldbda/configure.zcml
A mysqldbda/trunk/src/mysqldbda/mysqldbda-configure.zcml
A mysqldbda/trunk/src/mysqldbda/tests/
D mysqldbda/trunk/tests/
-=-
Added: mysqldbda/trunk/CHANGES.txt
===================================================================
--- mysqldbda/trunk/CHANGES.txt (rev 0)
+++ mysqldbda/trunk/CHANGES.txt 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,8 @@
+=======
+CHANGES
+=======
+
+1.0.1 (2008-02-20)
+------------------
+
+- Package eggification
Deleted: mysqldbda/trunk/DEPENDENCIES.cfg
===================================================================
--- mysqldbda/trunk/DEPENDENCIES.cfg 2008-02-20 10:59:18 UTC (rev 84071)
+++ mysqldbda/trunk/DEPENDENCIES.cfg 2008-02-20 11:20:03 UTC (rev 84072)
@@ -1,2 +0,0 @@
-MySQLdb
-zope.rdb
Deleted: mysqldbda/trunk/PACKAGE.cfg
===================================================================
--- mysqldbda/trunk/PACKAGE.cfg 2008-02-20 10:59:18 UTC (rev 84071)
+++ mysqldbda/trunk/PACKAGE.cfg 2008-02-20 11:20:03 UTC (rev 84072)
@@ -1,18 +0,0 @@
-# Load the license from an external source, so we don't have to keep a
-# copy of it sitting around:
-<load>
- LICENSE.txt http://svn.zope.org/*checkout*/Zope3/trunk/ZopePublicLicense.txt?rev=25177
-</load>
-
-# Add a few things to the distribution root.
-<distribution>
- README.txt
-</distribution>
-
-# Specify what is included in the component.
-<collection>
- *.txt
- *.py
- *.zcml
- tests
-</collection>
Deleted: mysqldbda/trunk/PUBLICATION.cfg
===================================================================
--- mysqldbda/trunk/PUBLICATION.cfg 2008-02-20 10:59:18 UTC (rev 84071)
+++ mysqldbda/trunk/PUBLICATION.cfg 2008-02-20 11:20:03 UTC (rev 84072)
@@ -1,9 +0,0 @@
-Metadata-Version: 1.0
-Name: mysqldbda
-Summary: MySQL Database Adapter for Zope 3
-Author: Zope Corporation and Contributors
-Author-email: zope3-dev at zope.org
-License: ZPL 2.1
-Description:
- This package allows Zope 3 to connect to any MySQL database via
- the common Zope 3 RDB connection facilities.
Deleted: mysqldbda/trunk/README.txt
===================================================================
--- mysqldbda/trunk/README.txt 2008-02-20 10:59:18 UTC (rev 84071)
+++ mysqldbda/trunk/README.txt 2008-02-20 11:20:03 UTC (rev 84072)
@@ -1,72 +0,0 @@
-This files helps you installing the MySQL Database adapter in Zope 3
-In this document I'm assuming your Zope3 lives in ~/Zope3.
-
-Installing mysqldbda
-
- 1. Check out the mysqldbda product into ~/Zope3/src
-
- cd ~/Zope3/src
- cvs -d :pserver:anonymous at cvs.zope.org:/cvs-repository login
- cvs -d :pserver:anonymous at cvs.zope.org:/cvs-repository checkout \
- mysqldbda
-
- 2. Create a file named 'mysqldbda-configure.zcml' inside
- ~/Zope3/package-includes with the following contents:
-
- <include package='mysqldbda' />
-
-Creating Database Connections
-
- It is time to add some connections. A connection in Zope 3 is
- registered as a utility.
-
- 3. Open a web browser on your Zope root folder (http://localhost:8080/ if
- you use the default settings in zope.conf.in).
-
- 4. Click on the 'Manage Site' action on the right side of the
- screen. You should see a screen which reads 'Common Site
- Management Tasks'
-
- 5. Around the middle of that page, you should see a link named 'Add
- Utility'. Click on it.
-
- 6. Select 'MySQL DA' and type in a name at the bottom of the page.
-
- 7. Enter the database connection string. It looks like this:
-
- dbi://username:password@host:port/databasename
-
- 8. Click on the 'Add' button.
-
- 9. You should be on a page which reads 'Add Database Connection
- Registration'. There you can configure the permission needed to
- use the database connection, the name of the registration and the
- registration status. You can use any name for 'Register As'
- field, as long as it doesn't clash with an existing one. Choose a
- permission. Choose between 'Registered' and 'Active' for the
- 'Registration Status'. Only one component of a kind can be
- 'Active' at a time, so be careful.
-
- 10. You should be redirected to the 'Edit' screen of the connection
- utility.
-
- 11. If you want to, you can go to the Test page and execute arbitrary SQL
- queries to see whether the connection is working as expected.
-
-Using SQL Scripts
-
- You can create SQL Scripts in the content space. For example:
-
- 12. Go to Zope root.
-
- 13. Add an SQL script (you can use the Common Tasks box on the left, or
- the Add action on the right).
-
- 14. Click on the name of your new SQL script.
-
- 15. Choose a connection name (the one you entered in step 29) from the
- drop-down.
-
- 16. Enter your query and click on the 'Save Changes' button.
-
- 17. You can test the script in the -- surprise! -- Test page.
\ No newline at end of file
Deleted: mysqldbda/trunk/SETUP.cfg
===================================================================
--- mysqldbda/trunk/SETUP.cfg 2008-02-20 10:59:18 UTC (rev 84071)
+++ mysqldbda/trunk/SETUP.cfg 2008-02-20 11:20:03 UTC (rev 84072)
@@ -1,5 +0,0 @@
-# Tell zpkg how to install the ZCML slugs.
-
-<data-files zopeskel/etc/package-includes>
- mysqldbda-*.zcml
-</data-files>
Deleted: mysqldbda/trunk/__init__.py
===================================================================
--- mysqldbda/trunk/__init__.py 2008-02-20 10:59:18 UTC (rev 84071)
+++ mysqldbda/trunk/__init__.py 2008-02-20 11:20:03 UTC (rev 84072)
@@ -1 +0,0 @@
-# Make directory a package
Deleted: mysqldbda/trunk/adapter.py
===================================================================
--- mysqldbda/trunk/adapter.py 2008-02-20 10:59:18 UTC (rev 84071)
+++ mysqldbda/trunk/adapter.py 2008-02-20 11:20:03 UTC (rev 84072)
@@ -1,107 +0,0 @@
-##############################################################################
-#
-# 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 2004/10/10 mriya3
-"""
-
-import sys
-
-from zope.interface import directlyProvides
-from zope.rdb.interfaces import IZopeConnection
-from zope.rdb import ZopeDatabaseAdapter, parseDSN
-from zope.publisher.interfaces import Retry
-
-import MySQLdb
-
-
-class IMySQLZopeConnection(IZopeConnection):
- """A marker interface stating that this connection uses the MySQL SQL."""
-
-
-class MySQLStringConverter:
-
- def __init__(self, encoding):
- self.encoding = encoding
-
- def __call__(self, string):
- if isinstance(string, str):
- return string.decode(self.encoding)
- return string
-
-class MySQLdbAdapter(ZopeDatabaseAdapter):
- """A MySQLdb adapter for Zope3"""
-
- # MySQLdb types codes
- __STRINGtypes = (1, 247, 254, 253)
- __BINARYtypes = (252, 251, 250, 249)
- __DATEtypes = (10, 14)
- __DATETIMEtypes = (7, 12)
- __NUMBERtypes = (0, 5, 4, 9, 3, 8, 1, 13)
- __TIMEtypes = (11)
-
- # Default string converter
- __stringConverter = MySQLStringConverter('UTF-8')
-
- def _connection_factory(self):
- """Create a MySQLdb DBI connection based on the DSN"""
-
- conn_info = parseDSN(self.dsn)
-
- connection = 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'))
- self.__stringConverter = MySQLStringConverter(self.getEncoding())
- return connection
-
- def getConverter(self, type):
- 'See IDBITypeInfo'
- if type in self.__STRINGtypes:
- return self.__stringConverter
- return self.identity
-
- def identity(self, x):
- return x
-
- def __call__(self):
- connection = ZopeDatabaseAdapter.__call__(self)
- directlyProvides(connection, IMySQLZopeConnection)
- return connection
-
- def isConnected(self):
- """Check if we are connected to a database.
-
- Try to solve the dissapearing connection problem. For background, see
- http://mail.zope.org/pipermail/zope3-dev/2005-December/017052.html
- """
- if self._v_connection is None:
- return False
- try:
- # Note, this might automatically re-connect to the DB
- # but then again might not... I've seen both.
- self._v_connection.ping()
- except MySQLdb.OperationalError:
- retry = Retry(sys.exc_info())
- try:
- # this is a bare except because at this point
- # we are just trying to be nice closing the connection.
- self._v_connection.close()
- except:
- pass
- self._v_connection = None
- # raise a retry exception and let the publisher try again
- raise retry
- return True
Added: mysqldbda/trunk/bootstrap.py
===================================================================
--- mysqldbda/trunk/bootstrap.py (rev 0)
+++ mysqldbda/trunk/bootstrap.py 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Property changes on: mysqldbda/trunk/bootstrap.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: mysqldbda/trunk/buildout.cfg
===================================================================
--- mysqldbda/trunk/buildout.cfg (rev 0)
+++ mysqldbda/trunk/buildout.cfg 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,9 @@
+[buildout]
+index = http://download.zope.org/zope3.4
+develop = .
+parts = test
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = mysqldbda
+defaults = ['--tests-pattern', '^f?tests$', '-v']
Deleted: mysqldbda/trunk/configure.zcml
===================================================================
--- mysqldbda/trunk/configure.zcml 2008-02-20 10:59:18 UTC (rev 84071)
+++ mysqldbda/trunk/configure.zcml 2008-02-20 11:20:03 UTC (rev 84072)
@@ -1,37 +0,0 @@
-<configure
- xmlns="http://namespaces.zope.org/zope"
- xmlns:browser="http://namespaces.zope.org/browser"
- i18n_domain="mysqldbda">
-
- <class class=".adapter.MySQLdbAdapter">
- <factory id="zope.da.MySQLdbDA" />
- <require
- permission="zope.rdb.Use"
- interface="zope.rdb.interfaces.IZopeDatabaseAdapter"
- />
- <require
- permission="zope.ManageServices"
- interface="zope.rdb.interfaces.IZopeDatabaseAdapterManagement"
- />
- </class>
-
- <browser:addform
- name="AddMySQLdbDA"
- schema="zope.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"
- />
-
-</configure>
Deleted: mysqldbda/trunk/mysqldbda-configure.zcml
===================================================================
--- mysqldbda/trunk/mysqldbda-configure.zcml 2008-02-20 10:59:18 UTC (rev 84071)
+++ mysqldbda/trunk/mysqldbda-configure.zcml 2008-02-20 11:20:03 UTC (rev 84072)
@@ -1 +0,0 @@
-<include package="mysqldbda" />
\ No newline at end of file
Added: mysqldbda/trunk/setup.py
===================================================================
--- mysqldbda/trunk/setup.py (rev 0)
+++ mysqldbda/trunk/setup.py 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,61 @@
+##############################################################################
+#
+# Copyright (c) 2007 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Setup for mysqldbda package
+
+$Id$
+"""
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup(name='mysqldbda',
+ version = '1.0.1',
+ author='Zope Corporation and Contributors',
+ author_email='zope3-dev at zope.org',
+ description='MySQL Database adapter',
+ long_description=(
+ read('README.txt')
+ + '\n\n' +
+ 'Detailed Dcoumentation\n' +
+ '======================\n'
+ + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ keywords = "mysql database adapter",
+ classifiers = [
+ 'Development Status :: 5 - Production/Stable',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Framework :: Zope3'],
+ url='http://cheeseshop.python.org/pypi/z3c.batching',
+ license='ZPL 2.1',
+ packages=find_packages('src'),
+ package_dir = {'': 'src'},
+ install_requires = ['setuptools',
+ 'zope.interface',
+ 'zope.schema',
+ 'zope.rdb',
+ 'zope.publisher',
+ 'zope.app.form',
+ ],
+ include_package_data = True,
+ zip_safe = False,
+ )
Property changes on: mysqldbda/trunk/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: mysqldbda/trunk/src/mysqldbda/DEPENDENCIES.cfg (from rev 84070, mysqldbda/trunk/DEPENDENCIES.cfg)
===================================================================
--- mysqldbda/trunk/src/mysqldbda/DEPENDENCIES.cfg (rev 0)
+++ mysqldbda/trunk/src/mysqldbda/DEPENDENCIES.cfg 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,2 @@
+MySQLdb
+zope.rdb
Copied: mysqldbda/trunk/src/mysqldbda/PACKAGE.cfg (from rev 84070, mysqldbda/trunk/PACKAGE.cfg)
===================================================================
--- mysqldbda/trunk/src/mysqldbda/PACKAGE.cfg (rev 0)
+++ mysqldbda/trunk/src/mysqldbda/PACKAGE.cfg 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,18 @@
+# Load the license from an external source, so we don't have to keep a
+# copy of it sitting around:
+<load>
+ LICENSE.txt http://svn.zope.org/*checkout*/Zope3/trunk/ZopePublicLicense.txt?rev=25177
+</load>
+
+# Add a few things to the distribution root.
+<distribution>
+ README.txt
+</distribution>
+
+# Specify what is included in the component.
+<collection>
+ *.txt
+ *.py
+ *.zcml
+ tests
+</collection>
Copied: mysqldbda/trunk/src/mysqldbda/PUBLICATION.cfg (from rev 84070, mysqldbda/trunk/PUBLICATION.cfg)
===================================================================
--- mysqldbda/trunk/src/mysqldbda/PUBLICATION.cfg (rev 0)
+++ mysqldbda/trunk/src/mysqldbda/PUBLICATION.cfg 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,9 @@
+Metadata-Version: 1.0
+Name: mysqldbda
+Summary: MySQL Database Adapter for Zope 3
+Author: Zope Corporation and Contributors
+Author-email: zope3-dev at zope.org
+License: ZPL 2.1
+Description:
+ This package allows Zope 3 to connect to any MySQL database via
+ the common Zope 3 RDB connection facilities.
Copied: mysqldbda/trunk/src/mysqldbda/README.txt (from rev 84070, mysqldbda/trunk/README.txt)
===================================================================
--- mysqldbda/trunk/src/mysqldbda/README.txt (rev 0)
+++ mysqldbda/trunk/src/mysqldbda/README.txt 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,72 @@
+This files helps you installing the MySQL Database adapter in Zope 3
+In this document I'm assuming your Zope3 lives in ~/Zope3.
+
+Installing mysqldbda
+
+ 1. Check out the mysqldbda product into ~/Zope3/src
+
+ cd ~/Zope3/src
+ cvs -d :pserver:anonymous at cvs.zope.org:/cvs-repository login
+ cvs -d :pserver:anonymous at cvs.zope.org:/cvs-repository checkout \
+ mysqldbda
+
+ 2. Create a file named 'mysqldbda-configure.zcml' inside
+ ~/Zope3/package-includes with the following contents:
+
+ <include package='mysqldbda' />
+
+Creating Database Connections
+
+ It is time to add some connections. A connection in Zope 3 is
+ registered as a utility.
+
+ 3. Open a web browser on your Zope root folder (http://localhost:8080/ if
+ you use the default settings in zope.conf.in).
+
+ 4. Click on the 'Manage Site' action on the right side of the
+ screen. You should see a screen which reads 'Common Site
+ Management Tasks'
+
+ 5. Around the middle of that page, you should see a link named 'Add
+ Utility'. Click on it.
+
+ 6. Select 'MySQL DA' and type in a name at the bottom of the page.
+
+ 7. Enter the database connection string. It looks like this:
+
+ dbi://username:password@host:port/databasename
+
+ 8. Click on the 'Add' button.
+
+ 9. You should be on a page which reads 'Add Database Connection
+ Registration'. There you can configure the permission needed to
+ use the database connection, the name of the registration and the
+ registration status. You can use any name for 'Register As'
+ field, as long as it doesn't clash with an existing one. Choose a
+ permission. Choose between 'Registered' and 'Active' for the
+ 'Registration Status'. Only one component of a kind can be
+ 'Active' at a time, so be careful.
+
+ 10. You should be redirected to the 'Edit' screen of the connection
+ utility.
+
+ 11. If you want to, you can go to the Test page and execute arbitrary SQL
+ queries to see whether the connection is working as expected.
+
+Using SQL Scripts
+
+ You can create SQL Scripts in the content space. For example:
+
+ 12. Go to Zope root.
+
+ 13. Add an SQL script (you can use the Common Tasks box on the left, or
+ the Add action on the right).
+
+ 14. Click on the name of your new SQL script.
+
+ 15. Choose a connection name (the one you entered in step 29) from the
+ drop-down.
+
+ 16. Enter your query and click on the 'Save Changes' button.
+
+ 17. You can test the script in the -- surprise! -- Test page.
\ No newline at end of file
Copied: mysqldbda/trunk/src/mysqldbda/SETUP.cfg (from rev 84070, mysqldbda/trunk/SETUP.cfg)
===================================================================
--- mysqldbda/trunk/src/mysqldbda/SETUP.cfg (rev 0)
+++ mysqldbda/trunk/src/mysqldbda/SETUP.cfg 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,5 @@
+# Tell zpkg how to install the ZCML slugs.
+
+<data-files zopeskel/etc/package-includes>
+ mysqldbda-*.zcml
+</data-files>
Copied: mysqldbda/trunk/src/mysqldbda/__init__.py (from rev 84070, mysqldbda/trunk/__init__.py)
===================================================================
--- mysqldbda/trunk/src/mysqldbda/__init__.py (rev 0)
+++ mysqldbda/trunk/src/mysqldbda/__init__.py 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1 @@
+# Make directory a package
Copied: mysqldbda/trunk/src/mysqldbda/adapter.py (from rev 84070, mysqldbda/trunk/adapter.py)
===================================================================
--- mysqldbda/trunk/src/mysqldbda/adapter.py (rev 0)
+++ mysqldbda/trunk/src/mysqldbda/adapter.py 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,107 @@
+##############################################################################
+#
+# 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 2004/10/10 mriya3
+"""
+
+import sys
+
+from zope.interface import directlyProvides
+from zope.rdb.interfaces import IZopeConnection
+from zope.rdb import ZopeDatabaseAdapter, parseDSN
+from zope.publisher.interfaces import Retry
+
+import MySQLdb
+
+
+class IMySQLZopeConnection(IZopeConnection):
+ """A marker interface stating that this connection uses the MySQL SQL."""
+
+
+class MySQLStringConverter:
+
+ def __init__(self, encoding):
+ self.encoding = encoding
+
+ def __call__(self, string):
+ if isinstance(string, str):
+ return string.decode(self.encoding)
+ return string
+
+class MySQLdbAdapter(ZopeDatabaseAdapter):
+ """A MySQLdb adapter for Zope3"""
+
+ # MySQLdb types codes
+ __STRINGtypes = (1, 247, 254, 253)
+ __BINARYtypes = (252, 251, 250, 249)
+ __DATEtypes = (10, 14)
+ __DATETIMEtypes = (7, 12)
+ __NUMBERtypes = (0, 5, 4, 9, 3, 8, 1, 13)
+ __TIMEtypes = (11)
+
+ # Default string converter
+ __stringConverter = MySQLStringConverter('UTF-8')
+
+ def _connection_factory(self):
+ """Create a MySQLdb DBI connection based on the DSN"""
+
+ conn_info = parseDSN(self.dsn)
+
+ connection = 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'))
+ self.__stringConverter = MySQLStringConverter(self.getEncoding())
+ return connection
+
+ def getConverter(self, type):
+ 'See IDBITypeInfo'
+ if type in self.__STRINGtypes:
+ return self.__stringConverter
+ return self.identity
+
+ def identity(self, x):
+ return x
+
+ def __call__(self):
+ connection = ZopeDatabaseAdapter.__call__(self)
+ directlyProvides(connection, IMySQLZopeConnection)
+ return connection
+
+ def isConnected(self):
+ """Check if we are connected to a database.
+
+ Try to solve the dissapearing connection problem. For background, see
+ http://mail.zope.org/pipermail/zope3-dev/2005-December/017052.html
+ """
+ if self._v_connection is None:
+ return False
+ try:
+ # Note, this might automatically re-connect to the DB
+ # but then again might not... I've seen both.
+ self._v_connection.ping()
+ except MySQLdb.OperationalError:
+ retry = Retry(sys.exc_info())
+ try:
+ # this is a bare except because at this point
+ # we are just trying to be nice closing the connection.
+ self._v_connection.close()
+ except:
+ pass
+ self._v_connection = None
+ # raise a retry exception and let the publisher try again
+ raise retry
+ return True
Copied: mysqldbda/trunk/src/mysqldbda/configure.zcml (from rev 84070, mysqldbda/trunk/configure.zcml)
===================================================================
--- mysqldbda/trunk/src/mysqldbda/configure.zcml (rev 0)
+++ mysqldbda/trunk/src/mysqldbda/configure.zcml 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1,37 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ xmlns:browser="http://namespaces.zope.org/browser"
+ i18n_domain="mysqldbda">
+
+ <class class=".adapter.MySQLdbAdapter">
+ <factory id="zope.da.MySQLdbDA" />
+ <require
+ permission="zope.rdb.Use"
+ interface="zope.rdb.interfaces.IZopeDatabaseAdapter"
+ />
+ <require
+ permission="zope.ManageServices"
+ interface="zope.rdb.interfaces.IZopeDatabaseAdapterManagement"
+ />
+ </class>
+
+ <browser:addform
+ name="AddMySQLdbDA"
+ schema="zope.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"
+ />
+
+</configure>
Copied: mysqldbda/trunk/src/mysqldbda/mysqldbda-configure.zcml (from rev 84070, mysqldbda/trunk/mysqldbda-configure.zcml)
===================================================================
--- mysqldbda/trunk/src/mysqldbda/mysqldbda-configure.zcml (rev 0)
+++ mysqldbda/trunk/src/mysqldbda/mysqldbda-configure.zcml 2008-02-20 11:20:03 UTC (rev 84072)
@@ -0,0 +1 @@
+<include package="mysqldbda" />
\ No newline at end of file
Copied: mysqldbda/trunk/src/mysqldbda/tests (from rev 84070, mysqldbda/trunk/tests)
More information about the Checkins
mailing list