Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xavier Thompson
erp5
Commits
2f7e29b1
Commit
2f7e29b1
authored
Jan 05, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
portal_type_class.py: add resetERP5WorkflowMethods.
parent
ffff687e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
31 deletions
+16
-31
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+5
-29
product/ERP5Type/dynamic/lazy_class.py
product/ERP5Type/dynamic/lazy_class.py
+9
-1
product/ERP5Type/dynamic/portal_type_class.py
product/ERP5Type/dynamic/portal_type_class.py
+2
-1
No files found.
product/ERP5Type/Base.py
View file @
2f7e29b1
...
...
@@ -125,19 +125,6 @@ def resetRegisteredERP5WorkflowMethod(portal_type=None):
class
ERP5WorkflowMethod
(
Method
):
def
__init__
(
self
,
method
,
id
=
None
,
reindex
=
1
):
"""
method - a callable object or a method
id - the workflow transition id. This is useful
to emulate "old" CMF behaviour but is
somehow inconsistent with the new registration based
approach implemented here.
We store id as _transition_id and use it
to register the transition for each portal
type and each workflow for which it is
applicable.
"""
self
.
_m
=
method
if
id
is
None
:
self
.
_transition_id
=
method
.
__name__
...
...
@@ -157,16 +144,7 @@ class ERP5WorkflowMethod(Method):
return
self
.
_transition_id
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
"""
Invoke the wrapped method, and deal with the results.
"""
if
getattr
(
self
,
'__name__'
,
None
)
in
(
'getPhysicalPath'
,
'getId'
):
# To prevent infinite recursion, 2 methods must have special treatment
# this is clearly not the best way to implement this but it is
# already better than what we had. I (JPS) would prefer to use
# critical sections in this part of the code and a
# thread variable which tells in which semantic context the code
# should be executed. - XXX
return
self
.
_m
(
instance
,
*
args
,
**
kw
)
# Build a list of transitions which may need to be invoked
...
...
@@ -193,30 +171,28 @@ class ERP5WorkflowMethod(Method):
candidate_transition_item_list
=
valid_invoke_once_item_list
+
\
self
.
_invoke_always
.
get
(
portal_type
,
{}).
items
()
#LOG('candidate_transition_item_list %s' % self.__name__, 0, str(candidate_transition_item_list))
# Try to return immediately if there are no transition to invoke
if
not
candidate_transition_item_list
:
return
apply
(
self
.
__dict__
[
'_m'
],
(
instance
,)
+
args
,
kw
)
if
instance
.
getTypeInfo
().
getTypeERP5WorkflowList
():
wf5_module
=
instance
.
getPortalObject
().
getDefaultModule
(
portal_type
=
"Workflow"
)
### Build the list of method which is call and will be invoked.
###
zwj:
Build the list of method which is call and will be invoked.
valid_transition_item_list
=
[]
for
wf_id
,
transition_list
in
candidate_transition_item_list
:
valid_list
=
[]
for
transition_id
in
transition_list
:
LOG
(
'Executing %s in %s'
%
(
transition_id
,
wf_id
),
WARNING
,
"lol"
)
LOG
(
'
zwj:
Executing %s in %s'
%
(
transition_id
,
wf_id
),
WARNING
,
"lol"
)
if
wf5_module
.
_getOb
(
wf_id
).
isERP5WorkflowMethodSupported
(
instance
,
wf5_module
.
_getOb
(
wf_id
).
_getOb
(
transition_id
)):
valid_list
.
append
(
transition_id
)
once_transition_key
=
once_transition_dict
.
get
((
wf_id
,
transition_id
))
transactional_variable
[
once_transition_key
]
=
1
else
:
raise
NotImplementedError
(
"The Transition is not supported by current state."
)
raise
UnsupportedWorkflowMethod
(
"The Transition is not supported by current state."
)
if
valid_list
:
valid_transition_item_list
.
append
((
wf_id
,
valid_list
))
### Execute method
###
zwj:
Execute method
for
wf_id
,
transition_list
in
valid_transition_item_list
:
for
tr
in
transition_list
:
method5
=
wf5_module
.
_getOb
(
wf_id
).
_getOb
(
tr
)
...
...
@@ -530,7 +506,6 @@ class PropertyHolder(object):
ERP5workflow_method
=
getattr
(
self
,
id
,
None
)
if
ERP5workflow_method
is
None
:
# XXX: We should pass 'tr_id' as second parameter.
ERP5workflow_method
=
ERP5WorkflowMethod
(
Base
.
_doNothing
)
setattr
(
self
,
id
,
ERP5workflow_method
)
if
once_per_transaction
:
...
...
@@ -674,6 +649,7 @@ def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
method_id
=
convertToMixedCase
(
tr_id
)
wf_id
=
ERP5Workflow
ptype_klass
.
registerERP5WorkflowMethod
(
method_id
,
wf_id
,
tr_id
,
0
)
LOG
(
"ERP5Workflow method %s is generated"
%
tr_id
,
WARNING
,
" for %s"
%
wf_id
)
def
initializePortalTypeDynamicWorkflowMethods
(
ptype_klass
,
portal_workflow
):
"""We should now make sure workflow methods are defined
...
...
product/ERP5Type/dynamic/lazy_class.py
View file @
2f7e29b1
...
...
@@ -286,6 +286,14 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
else
:
initializePortalTypeDynamicWorkflowMethods
(
cls
,
portal_workflow
)
portal_types
=
site
.
getDefaultModule
(
portal_type
=
"portal_types"
)
object_ptype
=
portal_types
.
_getOb
(
cls
.
__name__
,
None
)
if
hasattr
(
object_ptype
,
'erp5workflow_list'
):
ERP5Workflow
=
site
.
_getOb
(
"workflow_module"
,
None
)
if
ERP5Workflow
is
not
None
:
intializePortalTypeERP5WorkflowMethod
(
cls
,
ERP5Workflow
)
"""
portal_types = site.getDefaultModule(portal_type="portal_types")
object_ptype = portal_types._getOb(cls.__name__, None)
if object_ptype is not None:
...
...
@@ -294,7 +302,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
ERP5Workflow = getattr(site, "workflow_module", None)
if ERP5Workflow is not None:
intializePortalTypeERP5WorkflowMethod(cls, ERP5Workflow)
"""
# portal type group methods, isNodeType, isResourceType...
from
Products.ERP5Type.ERP5Type
import
ERP5TypeInformation
# XXX possible optimization:
...
...
product/ERP5Type/dynamic/portal_type_class.py
View file @
2f7e29b1
...
...
@@ -33,7 +33,7 @@ import inspect
import
transaction
from
Products.ERP5Type.mixin.temporary
import
TemporaryDocumentMixin
from
Products.ERP5Type.Base
import
resetRegisteredWorkflowMethod
from
Products.ERP5Type.Base
import
resetRegisteredWorkflowMethod
,
resetRegisteredERP5WorkflowMethod
from
.
import
aq_method_lock
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Utils
import
setDefaultClassProperties
...
...
@@ -388,6 +388,7 @@ def synchronizeDynamicModules(context, force=False):
# methods adds/registers/wraps existing methods, but does not
# remove old chains. Do it now.
resetRegisteredWorkflowMethod
()
resetRegisteredERP5WorkflowMethod
()
# Some method generations are based on portal methods, and portal
# methods cache results. So it is safer to invalidate the cache.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment