Commit 8529fae3 authored by Łukasz Nowak's avatar Łukasz Nowak

- do not depend anymore on erp5.recipe.createsite


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33257 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5a0f481d
...@@ -32,7 +32,6 @@ setup( ...@@ -32,7 +32,6 @@ setup(
namespace_packages = ['erp5', 'erp5.recipe'], namespace_packages = ['erp5', 'erp5.recipe'],
install_requires = [ install_requires = [
'plone.recipe.zope2instance', 'plone.recipe.zope2instance',
'erp5.recipe.createsite',
], ],
zip_safe=False, zip_safe=False,
entry_points = {'zc.buildout': ['default = %s:Recipe' % name]}, entry_points = {'zc.buildout': ['default = %s:Recipe' % name]},
......
...@@ -17,12 +17,11 @@ import os, sys ...@@ -17,12 +17,11 @@ import os, sys
from string import Template from string import Template
import zc.buildout import zc.buildout
import plone.recipe.zope2instance import plone.recipe.zope2instance
import erp5.recipe.createsite
class WithMinusTemplate(Template): class WithMinusTemplate(Template):
idpattern = '[_a-z][-_a-z0-9]*' idpattern = '[_a-z][-_a-z0-9]*'
class Recipe(plone.recipe.zope2instance.Recipe, erp5.recipe.createsite.Recipe): class Recipe(plone.recipe.zope2instance.Recipe):
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
standalone_location = options.get('instancehome') standalone_location = options.get('instancehome')
if not standalone_location: if not standalone_location:
...@@ -162,11 +161,42 @@ class Recipe(plone.recipe.zope2instance.Recipe, erp5.recipe.createsite.Recipe): ...@@ -162,11 +161,42 @@ class Recipe(plone.recipe.zope2instance.Recipe, erp5.recipe.createsite.Recipe):
if not os.path.exists(options['zodb-path'].strip()) or \ if not os.path.exists(options['zodb-path'].strip()) or \
force_zodb_update: force_zodb_update:
# initialise ERP5 part only in case if ZODB not exist yet or it is forced self.update_zodb()
erp5.recipe.createsite.Recipe.install(self)
# we return nothing, as this is totally standalone installation # we return nothing, as this is totally standalone installation
return [] return []
def update_zodb(self):
options = self.options
zopectl_path = os.path.join(options['bin-directory'],
options['control-script'])
script_name = os.path.join(os.path.dirname(__file__),
'create_erp5_instance.py')
argv = [zopectl_path, 'run', script_name]
if options.get('portal_id'):
argv.extend(['--portal_id', options['portal_id']])
if options.get('erp5_sql_connection_string'):
argv.extend(['--erp5_sql_connection_string',
options['erp5_sql_connection_string']])
if options.get('cmf_activity_sql_connection_string'):
argv.extend(['--cmf_activity_sql_connection_string',
options['cmf_activity_sql_connection_string']])
if options.get('erp5_catalog_storage'):
argv.extend(['--erp5_catalog_storage',
options['erp5_catalog_storage']])
if options.get('user'):
# XXX read rom zope2instance section ?
argv.extend(['--initial-user',
options['user']])
argv.extend(['--bt5-path',
os.path.join(options['bt5-path'])])
argv.extend([bt for bt in options.get('bt5', '').split('\n') if bt])
assert os.spawnl(
os.P_WAIT, zopectl_path, *argv ) == 0
def build_zope_conf(self): def build_zope_conf(self):
options = self.options options = self.options
location = options['instancehome'] location = options['instancehome']
...@@ -189,4 +219,6 @@ class Recipe(plone.recipe.zope2instance.Recipe, erp5.recipe.createsite.Recipe): ...@@ -189,4 +219,6 @@ class Recipe(plone.recipe.zope2instance.Recipe, erp5.recipe.createsite.Recipe):
file(zope_conf_path, 'w').write(result) file(zope_conf_path, 'w').write(result)
def update(self): def update(self):
# if self.options.get('force-zodb-update','false').strip().lower() == 'true':
# return self.install()
return plone.recipe.zope2instance.Recipe.update(self) return plone.recipe.zope2instance.Recipe.update(self)
# Create an ERP5 instance
# usage: zopectl run create_erp5_instance [options] [business templates]
import os
from optparse import OptionParser
from urllib import unquote
from Testing.makerequest import makerequest
from AccessControl.SecurityManagement import newSecurityManager
parser = OptionParser()
parser.add_option("-p", "--portal_id", dest="portal_id",
help="The ID of the Portal", default="erp5")
parser.add_option("--erp5_sql_connection_string",
dest="erp5_sql_connection_string",
help="Connection String used for ZSQLCatalog "
"(use %20 for space)",
default="test test")
parser.add_option("--cmf_activity_sql_connection_string",
dest="cmf_activity_sql_connection_string",
help="Connection String used for CMFActivity")
parser.add_option("--erp5_catalog_storage",
dest="erp5_catalog_storage",
help="Business Template for Catalog Storage")
parser.add_option("-u", "--initial-user",
dest="user_and_pass",
help="User and Password, separated by :",
default="zope:zope")
parser.add_option("--bt5-path",
dest="bt5_path",
help="Path to folder containing business templates",
default="bt5")
(options, args) = parser.parse_args()
# cmf activity connection string defaults to zsqlcatalog's one
if not options.cmf_activity_sql_connection_string:
options.cmf_activity_sql_connection_string = \
options.erp5_sql_connection_string
# connection strings have to contain a space, for conveniance, this space can
# be replaced by %20 character.
options.erp5_sql_connection_string =\
unquote(options.erp5_sql_connection_string)
options.cmf_activity_sql_connection_string =\
unquote(options.cmf_activity_sql_connection_string)
username, password = options.user_and_pass.split(':')
try:
import transaction
except ImportError:
class Transaction:
def commit(self):
return get_transaction().commit()
transaction = Transaction()
app = makerequest(app)
user = app.acl_users.getUserById(username)
if user is None:
uf = app.acl_users
uf._doAddUser(username, password, ['Manager', 'Member', 'Assignee',
'Assignor', 'Author'], [])
user = uf.getUserById(username)
newSecurityManager(None, user.__of__(app.acl_users))
portal = getattr(app, options.portal_id, None)
if portal is None:
print 'Adding ERP5 site %s' % options.portal_id
app.manage_addProduct['ERP5'].manage_addERP5Site(
id=options.portal_id,
erp5_sql_connection_string=options.erp5_sql_connection_string,
cmf_activity_sql_connection_string=\
options.cmf_activity_sql_connection_string,
erp5_catalog_storage='erp5_mysql_innodb_catalog')
transaction.commit()
portal = app._getOb(options.portal_id)
# set preference for erp5_subversion
from App.config import getConfiguration
default_site_preference = portal.portal_preferences.default_site_preference
instance_home = getConfiguration().instancehome
default_site_preference.edit(
preferred_subversion_working_copy_list=['%s/bt5/' % instance_home])
if default_site_preference.getPreferenceState() == 'disabled':
default_site_preference.enable()
# install our business templates
bt5_list = []
for arg in args:
bt_path = os.path.join(options.bt5_path, arg)
installed_bt = portal.portal_templates.getInstalledBusinessTemplate(arg)
if installed_bt is not None:
# XXX this way works only for extracted business template, not for
# *.bt5 packed business template.
version = file('%s/bt/version' % bt_path).read().strip()
revision = file('%s/bt/revision' % bt_path).read().strip()
if version == installed_bt.getVersion() and \
revision == installed_bt.getRevision():
print 'Skipping bt %s' % bt_path
continue
else:
print 'Updating bt %s' % bt_path
else:
print 'Installing bt %s' % bt_path
bt = portal.portal_templates.download(bt_path)
bt.install(force=True)
transaction.commit()
transaction.commit()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment