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
Matevz Golob
erp5
Commits
e6403cdd
Commit
e6403cdd
authored
Jan 06, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bt5_prototype: Add InstallationTree class
parent
ebc8d442
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
48 deletions
+57
-48
product/ERP5/Document/BusinessPackage.py
product/ERP5/Document/BusinessPackage.py
+57
-48
No files found.
product/ERP5/Document/BusinessPackage.py
View file @
e6403cdd
...
...
@@ -28,6 +28,7 @@
##############################################################################
import
fnmatch
,
re
,
gc
import
hashlib
import
transaction
from
copy
import
deepcopy
from
collections
import
defaultdict
...
...
@@ -292,46 +293,53 @@ class PathTemplatePackageItem(Implicit, Persistent):
container
.
_setObject
(
object_id
,
obj
)
obj
=
container
.
_getOb
(
object_id
)
# Regenerate local roles for all paths in this business template
p
=
context
.
getPortalObject
()
portal_type_role_list_len_dict
=
{}
update_dict
=
defaultdict
(
list
)
for
path
in
self
.
_objects
:
obj
=
p
.
unrestrictedTraverse
(
path
,
None
)
# Ignore any object without PortalType (non-ERP5 objects)
try
:
portal_type
=
aq_base
(
obj
).
getPortalType
()
except
Exception
,
e
:
pass
def
createInstallationData
(
package_list
):
"""
Create installation object as well as adds new node on the installation tree
from the installed state
"""
data
=
{}
path_list
=
[]
# Create path_list to be installed by the installation
for
package
in
package_list
:
path_list
.
extend
(
package
.
getTemplatePathList
())
path_list
=
list
(
set
(
path_list
))
for
package
in
package_list
:
obj_dict
=
package
.
_path_item
.
_objects
for
path
in
path_list
:
if
not
data
.
has_key
(
path
):
data
[
path
]
=
[
obj_dict
[
path
]]
else
:
if
portal_type
not
in
p
.
portal_types
:
LOG
(
"BusinessTemplate"
,
WARNING
,
"Could not update Local Roles as Portal Type '%s' could not "
"be found"
%
portal_type
)
data
[
path
].
append
(
obj_dict
[
path
])
continue
# Compare the objects which are present in multiple numbers in data_list
for
path
,
obj_list
in
data_list
.
iteritems
():
# We use iteritems so that it'd be okay while we change the values
if
len
(
obj_list
)
==
1
:
data
[
path
]
=
obj_list
[
0
]
else
:
hash_func
=
hashlib
.
sha1
hash_list
=
[
hash_fuc
(
obj
.
asXML
()).
hexdigest
()
for
obj
in
obj_list
]
hash_list
=
set
(
hash_list
)
if
not
len
(
hash_list
)
==
1
:
raise
ValueError
(
'There is a conflict'
)
else
:
data
[
path
]
=
obj_list
[
0
]
if
portal_type
not
in
portal_type_role_list_len_dict
:
portal_type_role_list_len_dict
[
portal_type
]
=
\
len
(
p
.
portal_types
[
portal_type
].
getRoleInformationList
())
if
portal_type_role_list_len_dict
[
portal_type
]:
update_dict
[
portal_type
].
append
(
obj
)
if
update_dict
:
def
updateLocalRolesOnDocument
():
for
portal_type
,
obj_list
in
update_dict
.
iteritems
():
update
=
p
.
portal_types
[
portal_type
].
updateLocalRolesOnDocument
for
obj
in
obj_list
:
update
(
obj
)
LOG
(
"BusinessTemplate"
,
INFO
,
"Updated Local Roles for '%s' (%s)"
%
(
portal_type
,
obj
.
getRelativeUrl
()))
transaction
.
get
().
addBeforeCommitHook
(
updateLocalRolesOnDocument
)
class
InstallationState
(
object
):
return
data
class
InstallationTree
(
object
):
"""
Tree implemetation to manage install/update/remove between states.
This is a very rough code to explain what can be achieved. In real case,
this class should be a well defined ERP5 object and most possibly act as a
portal tool, cause there should be one installation tree per site(agree ??)
Data at every node:
('_path_item': PathTemplateItem, }
State Number:
1) ERP5Site
...
...
@@ -342,6 +350,9 @@ class InstallationState(object):
Leaf node: OFS State(with some default BP installed)
Trying to install a new BT5 should be like adding new node to the tree
Will show if faced by any conflict between states, but mostly will try to
solve by itself
How to pickle:
http://stackoverflow.com/questions/2134706/hitting-maximum-recursion-depth-using-pythons-pickle-cpickle
...
...
@@ -350,27 +361,25 @@ class InstallationState(object):
"""
def
__init__
(
self
,
state
):
"""
"""
self
.
root_status
=
False
# Installtion status of the combined packages
self
.
data_list
=
[]
# To be installed/update/deleted list of packages
self
.
current_level
=
1
def
__init__
(
self
,
data
):
self
.
data
=
data
# To be installed/update/deleted list of packages
self
.
children
=
[]
# List of child nodes
def
set
NewState
(
self
,
state
):
def
add
NewState
(
self
,
state
):
"""
In tree language, should act as set
N
ext node to the tree
In tree language, should act as set
n
ext node to the tree
This should add package list after comparing the states of
packages with the installed state. So even if we try to install multiple
packages at a time, it should be counted as one state being implented on
another installed state, i.e, the state of ERP5Site
"""
pass
self
.
children
.
append
(
state
)
def
install_package_list
(
self
,
package_list
):
def
mapToERP5Site
(
self
):
"""
Create a new state by comparing all BP combined built and the ERP5Site,
then calls setNewState to update the state
"""
# No need to save sha here, save it in business package itself
pass
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