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
Eteri
erp5
Commits
d72e5627
Commit
d72e5627
authored
Apr 12, 2021
by
Roque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_core: control on ERP5Site_setNewIdPerBundle if id remains equal and
new id generation script
parent
6058e5f3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
2 deletions
+109
-2
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFolderMigration.py
...teItem/portal_components/test.erp5.testFolderMigration.py
+28
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_generateIdFromCreationDate.py
...portal_skins/erp5_core/Base_generateIdFromCreationDate.py
+16
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_generateIdFromCreationDate.xml
...ortal_skins/erp5_core/Base_generateIdFromCreationDate.xml
+62
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_setNewIdPerBundle.py
...Item/portal_skins/erp5_core/ERP5Site_setNewIdPerBundle.py
+3
-2
No files found.
bt5/erp5_core_test/TestTemplateItem/portal_components/test.erp5.testFolderMigration.py
View file @
d72e5627
...
...
@@ -481,6 +481,34 @@ class TestFolderMigration(ERP5TypeTestCase, LogInterceptor):
self
.
assertEqual
(
self
.
folder
.
isBTree
(),
False
)
self
.
assertEqual
(
self
.
folder
.
isHBTree
(),
True
)
def
test_15_checkMigrationWorksIfIdsDontChange
(
self
):
"""
migrate folder using a script that leaves some objects with same ids
"""
# Create some objects
self
.
assertEqual
(
self
.
folder
.
getIdGenerator
(),
''
)
self
.
assertEqual
(
len
(
self
.
folder
),
0
)
obj1
=
self
.
newContent
()
self
.
assertEqual
(
obj1
.
getId
(),
'1'
)
obj2
=
self
.
newContent
()
self
.
assertEqual
(
obj2
.
getId
(),
'2'
)
obj3
=
self
.
newContent
(
id
=
'custom-id'
)
self
.
assertEqual
(
obj3
.
getId
(),
'custom-id'
)
self
.
tic
()
# call migration script Base_generateIdFromCreationDate that only changes int ids
self
.
folder
.
migrateToHBTree
(
migration_generate_id_method
=
"Base_generateIdFromCreationDate"
,
new_generate_id_method
=
"_generatePerDayId"
)
self
.
tic
()
# check object ids
from
DateTime
import
DateTime
date
=
DateTime
().
Date
()
date
=
date
.
replace
(
"/"
,
""
)
#1 y 2 should have new format id (because old ids were int)
self
.
assertEqual
(
obj1
.
getId
(),
'%s-1'
%
date
)
self
.
assertEqual
(
obj2
.
getId
(),
'%s-2'
%
date
)
#3 should have the same old id
self
.
assertEqual
(
obj3
.
getId
(),
'custom-id'
)
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestFolderMigration
))
...
...
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_generateIdFromCreationDate.py
0 → 100644
View file @
d72e5627
# retrieve a date from object and return the new id
if
obj
is
None
:
obj
=
context
# don't change custom (non-int) ids
old_id
=
obj
.
getId
()
if
not
old_id
.
isdigit
():
return
old_id
date
=
obj
.
getCreationDate
()
if
date
is
None
:
from
DateTime
import
DateTime
date
=
DateTime
()
date
=
date
.
Date
().
replace
(
'/'
,
''
)
return
"%s-%s"
%
(
date
,
old_id
)
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_generateIdFromCreationDate.xml
0 → 100644
View file @
d72e5627
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
obj=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_generateIdFromCreationDate
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5Site_setNewIdPerBundle.py
View file @
d72e5627
...
...
@@ -4,5 +4,6 @@ method = getattr(context, method)
for
id_
in
id_list
:
ob
=
folder
.
get
(
id_
)
new_id
=
method
(
ob
)
if
new_id
!=
id_
:
ob
.
setDefaultActivateParameterDict
(
activate_kw
)
ob
.
setId
(
new_id
)
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