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
Alain Takoudjou
erp5
Commits
3fe7aa1e
Commit
3fe7aa1e
authored
Jul 27, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify automatic migration of action providers
parent
a3540a95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
20 deletions
+6
-20
product/ERP5Type/patches/ActionsTool.py
product/ERP5Type/patches/ActionsTool.py
+6
-20
No files found.
product/ERP5Type/patches/ActionsTool.py
View file @
3fe7aa1e
...
...
@@ -13,8 +13,6 @@
##############################################################################
import
logging
import
transaction
from
Acquisition
import
aq_parent
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -29,23 +27,14 @@ except ImportError:
def
migrateNonProviders
(
portal_actions
):
portal_actions_path
=
'/'
.
join
(
portal_actions
.
getPhysicalPath
())
root
=
portal_actions
.
getPhysicalRoot
()
# Discard all changes so far, we'll restart the request later so no changes
# are lost.
root
.
_p_jar
.
sync
()
txn
=
transaction
.
get
()
portal_actions
=
root
.
unrestrictedTraverse
(
portal_actions_path
)
portal
=
aq_parent
(
portal_actions
)
portal
=
portal_actions
.
getPortalObject
()
action_providers
=
list
(
portal_actions
.
action_providers
)
for
provider_name
in
portal_actions
.
listActionProviders
():
provider
=
getattr
(
portal
,
provider_name
)
if
(
getattr
(
provider
,
'_actions'
,
())
and
getattr
(
provider
,
'listActionInfos'
,
None
)
is
None
):
msg
=
(
'migrating actions from %r to %r'
%
(
portal_actions_path
,
'/'
.
join
(
provider
.
getPhysicalPath
())))
logger
.
warning
(
msg
)
txn
.
note
(
msg
)
logger
.
info
(
'migrating actions from %r to %r'
,
portal_actions_path
,
'/'
.
join
(
provider
.
getPhysicalPath
()))
portal_actions
.
_actions
+=
provider
.
_actions
del
provider
.
_actions
if
(
getattr
(
provider
,
'listActionInfos'
,
None
)
is
None
and
...
...
@@ -54,12 +43,6 @@ def migrateNonProviders(portal_actions):
not
(
IActionProvider_providedBy
(
provider
))):
action_providers
.
remove
(
provider_name
)
portal_actions
.
action_providers
=
tuple
(
action_providers
)
txn
.
note
(
'Migrated actions from non IActionProviders to portal_actions'
)
txn
.
commit
()
# restart the transaction with actions already migrated
from
ZODB.POSException
import
ConflictError
raise
ConflictError
(
'Action Migration Completed, please restart request.'
)
ActionsTool_listFilteredActionsFor
=
ActionsTool
.
listFilteredActionsFor
...
...
@@ -96,9 +79,12 @@ def listFilteredActionsFor(self, object=None):
# for Action Providers written for CMF versions before 1.5
actions
.
extend
(
self
.
_listActionInfos
(
provider
,
object
)
)
else
:
# This should only be triggered once
# We're in 2.12 and we need to migrate objects that are no longer
# IActionProviders:
migrateNonProviders
(
self
)
# Recompute from beginning
return
self
.
listFilteredActionsFor
(
object
=
object
)
actions
.
sort
(
key
=
lambda
x
:
x
.
get
(
'priority'
,
0
))
# Reorganize the actions by category.
...
...
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