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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kasra Jamshidi
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 @@
...
@@ -13,8 +13,6 @@
##############################################################################
##############################################################################
import
logging
import
logging
import
transaction
from
Acquisition
import
aq_parent
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
...
@@ -29,23 +27,14 @@ except ImportError:
...
@@ -29,23 +27,14 @@ except ImportError:
def
migrateNonProviders
(
portal_actions
):
def
migrateNonProviders
(
portal_actions
):
portal_actions_path
=
'/'
.
join
(
portal_actions
.
getPhysicalPath
())
portal_actions_path
=
'/'
.
join
(
portal_actions
.
getPhysicalPath
())
root
=
portal_actions
.
getPhysicalRoot
()
portal
=
portal_actions
.
getPortalObject
()
# 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
)
action_providers
=
list
(
portal_actions
.
action_providers
)
action_providers
=
list
(
portal_actions
.
action_providers
)
for
provider_name
in
portal_actions
.
listActionProviders
():
for
provider_name
in
portal_actions
.
listActionProviders
():
provider
=
getattr
(
portal
,
provider_name
)
provider
=
getattr
(
portal
,
provider_name
)
if
(
getattr
(
provider
,
'_actions'
,
())
and
if
(
getattr
(
provider
,
'_actions'
,
())
and
getattr
(
provider
,
'listActionInfos'
,
None
)
is
None
):
getattr
(
provider
,
'listActionInfos'
,
None
)
is
None
):
msg
=
(
'migrating actions from %r to %r'
%
logger
.
info
(
'migrating actions from %r to %r'
,
(
portal_actions_path
,
'/'
.
join
(
provider
.
getPhysicalPath
())))
portal_actions_path
,
'/'
.
join
(
provider
.
getPhysicalPath
()))
logger
.
warning
(
msg
)
txn
.
note
(
msg
)
portal_actions
.
_actions
+=
provider
.
_actions
portal_actions
.
_actions
+=
provider
.
_actions
del
provider
.
_actions
del
provider
.
_actions
if
(
getattr
(
provider
,
'listActionInfos'
,
None
)
is
None
and
if
(
getattr
(
provider
,
'listActionInfos'
,
None
)
is
None
and
...
@@ -54,12 +43,6 @@ def migrateNonProviders(portal_actions):
...
@@ -54,12 +43,6 @@ def migrateNonProviders(portal_actions):
not
(
IActionProvider_providedBy
(
provider
))):
not
(
IActionProvider_providedBy
(
provider
))):
action_providers
.
remove
(
provider_name
)
action_providers
.
remove
(
provider_name
)
portal_actions
.
action_providers
=
tuple
(
action_providers
)
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
ActionsTool_listFilteredActionsFor
=
ActionsTool
.
listFilteredActionsFor
...
@@ -96,9 +79,12 @@ def listFilteredActionsFor(self, object=None):
...
@@ -96,9 +79,12 @@ def listFilteredActionsFor(self, object=None):
# for Action Providers written for CMF versions before 1.5
# for Action Providers written for CMF versions before 1.5
actions
.
extend
(
self
.
_listActionInfos
(
provider
,
object
)
)
actions
.
extend
(
self
.
_listActionInfos
(
provider
,
object
)
)
else
:
else
:
# This should only be triggered once
# We're in 2.12 and we need to migrate objects that are no longer
# We're in 2.12 and we need to migrate objects that are no longer
# IActionProviders:
# IActionProviders:
migrateNonProviders
(
self
)
migrateNonProviders
(
self
)
# Recompute from beginning
return
self
.
listFilteredActionsFor
(
object
=
object
)
actions
.
sort
(
key
=
lambda
x
:
x
.
get
(
'priority'
,
0
))
actions
.
sort
(
key
=
lambda
x
:
x
.
get
(
'priority'
,
0
))
# Reorganize the actions by category.
# 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