[Erp5-report] r33821 rafael - in /erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinst...
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed Mar 17 20:50:41 CET 2010
Author: rafael
Date: Wed Mar 17 20:50:41 2010
New Revision: 33821
URL: http://svn.erp5.org?rev=33821&view=rev
Log:
Use erp5.recipe.mysqldatabase to create the database.
Modified:
erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/setup.py
erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py
Modified: erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/setup.py
URL: http://svn.erp5.org/erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/setup.py?rev=33821&r1=33820&r2=33821&view=diff
==============================================================================
--- erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/setup.py [utf8] (original)
+++ erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/setup.py [utf8] Wed Mar 17 20:50:41 2010
@@ -32,6 +32,7 @@
namespace_packages = ['erp5', 'erp5.recipe'],
install_requires = [
'plone.recipe.zope2instance',
+ 'erp5.recipe.mysqldatabase',
],
zip_safe=False,
entry_points = {'zc.buildout': ['default = %s:Recipe' % name]},
Modified: erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py
URL: http://svn.erp5.org/erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py?rev=33821&r1=33820&r2=33821&view=diff
==============================================================================
--- erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py [utf8] (original)
+++ erp5/trunk/buildout/local-eggs/erp5.recipe.standaloneinstance/src/erp5/recipe/standaloneinstance/__init__.py [utf8] Wed Mar 17 20:50:41 2010
@@ -17,6 +17,7 @@
from string import Template
import zc.buildout
import plone.recipe.zope2instance
+from erp5.recipe.mysqldatabase import Recipe as mysqlrecipe
class WithMinusTemplate(Template):
idpattern = '[_a-z][-_a-z0-9]*'
@@ -58,43 +59,9 @@
ws_locations = [d.location for d in ws]
if options.get('mysql_create_database', 'false').lower() == 'true':
- try:
- import MySQLdb
- except ImportError:
- raise ImportError('To be able to create database MySQLdb is required'
- ' Install system wide or use software generated python')
- mysql_database_name, mysql_user, mysql_password, mysql_port, mysql_host\
- = \
- options.get('mysql_database_name'), \
- options.get('mysql_user'), \
- options.get('mysql_password'), \
- options.get('mysql_port'), \
- options.get('mysql_host')
-
- if not (mysql_database_name and mysql_user):
- raise zc.buildout.UserError('mysql_database_name and mysql_user are '
- 'required to create database and grant privileges')
- connection = MySQLdb.connect(
- host = self.options.get('mysql_host'),
- port = int(self.options.get('mysql_port')),
- user = self.options.get('mysql_superuser'),
- passwd = self.options.get('mysql_superpassword'),
- )
- connection.autocommit(0)
- cursor = connection.cursor()
- cursor.execute(
- 'CREATE DATABASE IF NOT EXISTS %s DEFAULT CHARACTER SET utf8 COLLATE '
- 'utf8_unicode_ci' % mysql_database_name)
- privileges = ['GRANT ALL PRIVILEGES ON %s.* TO %s' % (
- mysql_database_name, mysql_user)]
-
- if mysql_host:
- privileges.append('@%s' % mysql_host)
- if mysql_password:
- privileges.append(' IDENTIFIED BY "%s"' % mysql_password)
- cursor.execute(''.join(privileges))
- connection.commit()
- connection.close()
+ # Use mysqldatabase recipe for Create the mysql database.
+ mysqlrecipe(self.buildout, self.name, self.options).install()
+
# What follows is a bit of a hack because the instance-setup mechanism
# is a bit monolithic. We'll run mkzopeinstance and then we'll
More information about the Erp5-report
mailing list