Commit f36a2373 authored by Julien Muchembled's avatar Julien Muchembled

Move BT workflows to erp5_core and fix indexation of first installed BT

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44836 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 41360bf4
......@@ -4687,23 +4687,6 @@ Business Template is a set of definitions, such as skins, portal types and categ
if not force:
self.checkDependencies()
from Products.ERP5.ERP5Site import ERP5Generator
generator_class = getattr(site, '_generator_class', ERP5Generator)
gen = generator_class()
# update activity tool first if necessary
if self.getTitle() == 'erp5_core':
if self.getTemplateUpdateTool():
gen.setupLastTools(site)
if not force and len(object_to_update) == 0:
# check if we have to update tools
if self.getTemplateUpdateTool():
LOG('Business Template', 0, 'Updating Tools')
gen.setup(site, 0, update=1)
if self.getTemplateUpdateBusinessTemplateWorkflow():
LOG('Business Template', 0, 'Updating Business Template Workflows')
gen.setupWorkflow(site)
return
# always created a trash bin because we may to save object already present
# but not in a previous business templates apart at creation of a new site
if trash_tool is not None and (len(object_to_update) > 0 or len(self.portal_templates) > 2):
......@@ -4752,19 +4735,12 @@ Business Template is a set of definitions, such as skins, portal types and categ
# update tools if necessary
if self.getTitle() == 'erp5_core':
if self.getTemplateUpdateTool():
if self.getTitle() == 'erp5_core' and self.getTemplateUpdateTool():
from Products.ERP5.ERP5Site import ERP5Generator
gen = getattr(site, '_generator_class', ERP5Generator)()
LOG('Business Template', 0, 'Updating Tools')
gen.setup(site, 0, update=1)
# check if we have to update business template workflow
if self.getTemplateUpdateBusinessTemplateWorkflow():
LOG('Business Template', 0, 'Updating Business Template Workflows')
gen.setupWorkflow(site)
# XXX keep TM in case update of workflow doesn't work
# self._v_txn = WorkflowUpdateTM()
# self._v_txn.register(update=1, gen=gen, site=site)
# remove trashbin if empty
if trashbin is not None:
if len(trashbin) == 0:
......@@ -5576,41 +5552,3 @@ Business Template is a set of definitions, such as skins, portal types and categ
# a default class value to None
for key in BusinessTemplate._item_name_list:
setattr(BusinessTemplate, key, None)
# Transaction Manager used for update of business template workflow
# XXX update seems to works without it
# from Shared.DC.ZRDB.TM import TM
# class WorkflowUpdateTM(TM):
# _p_oid=_p_changed=_registered=None
# _update = 0
# def __init__(self, ):
# LOG('init TM', 0, '')
# def register(self, update=0, gen=None, site=None):
# LOG('register TM', 0, update)
# self._gen = gen
# self._site = site
# self._update = update
# self._register()
# def tpc_prepare(self, *d, **kw):
# LOG("tpc_prepare", 0, self._update)
# if self._update:
# # do it one time
# self._update = 0
# LOG('call update of wf', 0, '')
# self._gen.setupWorkflow(self._site)
# def _finish(self, **kw):
# LOG('finish TM', 0, '')
# pass
# def _abort(self, **kw):
# LOG('abort TM', 0, '')
# pass
......@@ -1617,26 +1617,39 @@ class ERP5Generator(PortalGenerator):
return p
def setupLastTools(self, p, create_activities=True, **kw):
@classmethod
def bootstrap(cls, context, bt_name, item_name, content_id_list):
cwd = os.getcwd()
try:
os.chdir(getBootstrapBusinessTemplateUrl(bt_name))
from Products.ERP5.Document.BusinessTemplate import quote
traverse = context.unrestrictedTraverse
for root, dirs, files in os.walk(os.path.join(item_name, context.id)):
container_path = root.split(os.sep)[2:]
load = traverse(container_path)._importObjectFromFile
if container_path:
id_set = set(x[:-4] for x in files if x[-4:] == '.xml')
else:
id_set = set(quote(x) for x in content_id_list
if not context.hasObject(x))
dirs[:] = id_set.intersection(dirs)
for file in id_set:
load(os.path.join(root, file + '.xml'),
verify=False, set_owner=False, suppress_events=True)
finally:
os.chdir(cwd)
def setupLastTools(self, p, **kw):
"""
Set up finals tools
We want to set the activity tool only at the end to
make sure that we do not put un the queue the full reindexation
"""
# Add Activity Tool
if create_activities and not p.hasObject('portal_activities'):
addERP5Tool(p, 'portal_activities', 'Activity Tool')
# Initialize Activities
p.portal_activities.manageClearActivities(keep=0)
# Add several other tools, only at the end in order
# to make sure that they will be reindexed
addERP5Tool(p, 'portal_rules', 'Rule Tool')
addERP5Tool(p, 'portal_simulation', 'Simulation Tool')
addERP5Tool(p, 'portal_deliveries', 'Delivery Tool')
addERP5Tool(p, 'portal_orders', 'Order Tool')
def setupTemplateTool(self, p, **kw):
"""
Setup the Template Tool. Security must be set strictly.
......@@ -1883,23 +1896,12 @@ class ERP5Generator(PortalGenerator):
"""
Set up workflows for business templates
"""
workflow_list = ['business_template_building_workflow',
'business_template_installation_workflow']
tool = p.portal_workflow
for wf_id in ('business_template_building_workflow',
'business_template_installation_workflow'):
if wf_id in tool.objectIds():
tool.manage_delObjects([wf_id])
bootstrap_dir = getBootstrapDirectory()
business_template_building_workflow = os.path.join(
bootstrap_dir,
'business_template_building_workflow.xml')
tool._importObjectFromFile(business_template_building_workflow)
business_template_installation_workflow = os.path.join(
bootstrap_dir,
'business_template_installation_workflow.xml')
tool._importObjectFromFile(business_template_installation_workflow)
tool.setChainForPortalTypes( ( 'Business Template', ),
( 'business_template_building_workflow',
'business_template_installation_workflow' ) )
tool.manage_delObjects(filter(tool.hasObject, workflow_list))
self.bootstrap(tool, 'erp5_core', 'WorkflowTemplateItem', workflow_list)
tool.setChainForPortalTypes(('Business Template',), workflow_list)
def setupIndex(self, p, **kw):
# Make sure all tools and folders have been indexed
......@@ -2010,13 +2012,16 @@ class ERP5Generator(PortalGenerator):
if not update:
self.setupPermissions(p)
self.setupDefaultSkins(p)
assert not p.hasObject('portal_activities')
addERP5Tool(p, 'portal_activities', 'Activity Tool')
# Initialize Activities
p.portal_activities.manageClearActivities(keep=0)
if not p.hasObject('content_type_registry'):
self.setupMimetypes(p)
if not update:
self.setupWorkflow(p)
if not update:
self.setupWorkflow(p)
self.setupERP5Core(p,**kw)
# Make sure the cache is initialized
......
......@@ -23,6 +23,10 @@
<type>Base Type</type>
<workflow>base_type_interaction_workflow, dynamic_class_generation_interaction_workflow</workflow>
</chain>
<chain>
<type>Business Template</type>
<workflow>business_template_building_workflow, business_template_installation_workflow</workflow>
</chain>
<chain>
<type>Category</type>
<workflow>edit_workflow</workflow>
......
......@@ -70,7 +70,6 @@
<string>my_template_tool_id_list</string>
<string>my_template_preference_list</string>
<string>my_template_update_tool</string>
<string>my_template_update_business_template_workflow</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="CheckBoxField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_template_update_business_template_workflow</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>If checked, when installing the business template it will update workflow used by business templates</string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Update Business Template Workflows</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Products.Formulator.TALESField</string>
<string>TALESMethod</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.getTemplateUpdateBusinessTemplateWorkflow(0)</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="DCWorkflowDefinition" module="Products.DCWorkflow.DCWorkflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>business_template_building_workflow</string> </value>
</item>
<item>
<key> <string>initial_state</string> </key>
<value> <string>draft</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>state_var</string> </key>
<value> <string>building_state</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Business Template Building Workflow</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Scripts" module="Products.DCWorkflow.Scripts"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>scripts</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="States" module="Products.DCWorkflow.States"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_mapping</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>states</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="StateDefinition" module="Products.DCWorkflow.States"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>built</string> </value>
</item>
<item>
<key> <string>permission_roles</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Built</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>build</string>
<string>clean</string>
<string>clean_action</string>
<string>edit</string>
<string>rebuild_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<value>
<dictionary>
<item>
<key> <string>Access contents information</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>Modify portal content</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>View</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="StateDefinition" module="Products.DCWorkflow.States"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>draft</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Draft</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>build</string>
<string>build_action</string>
<string>clean</string>
<string>edit</string>
</tuple>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="StateDefinition" module="Products.DCWorkflow.States"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>modified</string> </value>
</item>
<item>
<key> <string>permission_roles</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Modified</string> </value>
</item>
<item>
<key> <string>transitions</string> </key>
<value>
<tuple>
<string>build</string>
<string>build_action</string>
<string>clean</string>
<string>edit</string>
</tuple>
</value>
</item>
<item>
<key> <string>type_list</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<value>
<dictionary>
<item>
<key> <string>Access contents information</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>Add portal content</string> </key>
<value>
<list>
<string>Reviewer</string>
</list>
</value>
</item>
<item>
<key> <string>Modify portal content</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>Review portal content</string> </key>
<value>
<list>
<string>Reviewer</string>
</list>
</value>
</item>
<item>
<key> <string>View</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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