Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush Tiwari
erp5
Commits
4a746445
Commit
4a746445
authored
Nov 16, 2016
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multiple_catalog: Python Scripts to create and delete multiple catalogs at a time
parent
5eaa62f4
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
348 additions
and
0 deletions
+348
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.py
...tem/portal_skins/erp5_core/CatalogTool_validateCatalog.py
+8
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.xml
...em/portal_skins/erp5_core/CatalogTool_validateCatalog.xml
+62
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.py
...Item/portal_skins/erp5_core/ERP5_createMultipleCatalog.py
+66
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.xml
...tem/portal_skins/erp5_core/ERP5_createMultipleCatalog.xml
+62
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.py
...Item/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.py
+18
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.xml
...tem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.xml
+62
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.py
...teItem/portal_skins/erp5_core/ERP5_restartDBConnection.py
+8
-0
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.xml
...eItem/portal_skins/erp5_core/ERP5_restartDBConnection.xml
+62
-0
No files found.
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.py
0 → 100644
View file @
4a746445
portal
=
context
.
getPortalObject
()
portal_catalog
=
portal
.
portal_catalog
for
i
in
range
(
101
,
164
):
catalog_id
=
'erp5_mysql_innodb%s'
%
i
catalog
=
getattr
(
portal_catalog
,
catalog_id
)
if
catalog
.
getValidationState
()
!=
'validated'
:
catalog
.
validate
()
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/CatalogTool_validateCatalog.xml
0 → 100644
View file @
4a746445
<?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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
CatalogTool_validateCatalog
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.py
0 → 100644
View file @
4a746445
portal
=
context
.
getPortalObject
()
original_connection_id
=
'test_connection'
original_deferred_connection_id
=
'erp5_sql_deferred_connection'
for
i
in
range
(
164
,
165
):
new_connection_id
=
'erp5_sql_connection%s'
%
str
(
i
)
new_deferred_connection_id
=
'erp5_sql_deferred_connection%s'
%
i
new_connection_string
=
'erp5_test_%(i)s@10.0.159.93:2099 testuser_%(i)s testpassword%(i)s'
%
{
'i'
:
i
}
# Skip this test if default connection string is not "test test".
original_connection
=
getattr
(
portal
,
original_connection_id
)
connection_string
=
original_connection
.
connection_string
if
(
connection_string
==
new_connection_string
):
message
=
'SKIPPED: default connection string is the same as the default catalog'
ZopeTestCase
.
_print
(
message
)
LOG
(
'Testing... '
,
0
,
message
)
addSQLConnection
=
portal
.
manage_addProduct
[
'ZMySQLDA'
]
\
.
manage_addZMySQLConnection
# Create new connectors
try
:
addSQLConnection
(
new_connection_id
,
''
,
new_connection_string
)
new_connection
=
portal
[
new_connection_id
]
new_connection
.
manage_open_connection
()
addSQLConnection
(
new_deferred_connection_id
,
''
,
new_connection_string
)
new_connection
=
portal
[
new_deferred_connection_id
]
new_connection
.
manage_open_connection
()
except
:
pass
# the transactionless connector must not be changed because this one
# creates the portal_ids otherwise it will create conflicts with uid
# objects
# Create new catalog
portal_catalog
=
portal
.
portal_catalog
erp5_catalog
=
portal_catalog
.
getSQLCatalog
()
original_catalog_id
=
'erp5_mysql_innodb'
new_catalog_id
=
original_catalog_id
+
str
(
i
)
new_catalog
=
portal_catalog
.
cloneCatalog
(
new_catalog_id
)
#new_catalog = portal_catalog.manage_clone(erp5_catalog, new_catalog_id)
#self.tic()
# Parse all methods in the new catalog in order to change the connector
source_sql_connection_id_list
=
list
((
original_connection_id
,
original_deferred_connection_id
))
destination_sql_connection_id_list
=
list
((
new_connection_id
,
new_deferred_connection_id
))
# Construct a mapping for connection ids.
sql_connection_id_dict
=
None
if
source_sql_connection_id_list
is
not
None
and
\
destination_sql_connection_id_list
is
not
None
:
sql_connection_id_dict
=
{}
for
source_sql_connection_id
,
destination_sql_connection_id
in
\
zip
(
source_sql_connection_id_list
,
destination_sql_connection_id_list
):
if
source_sql_connection_id
!=
destination_sql_connection_id
:
sql_connection_id_dict
[
source_sql_connection_id
]
=
\
destination_sql_connection_id
# Call the method to update the connection ids for the new catalog
portal_catalog
.
changeSQLConnectionIds
(
new_catalog
,
sql_connection_id_dict
)
# Clear the new catalog incase it uses some old connection string
new_catalog
.
manage_catalogClear
()
# Now validate the newly created catalog
#new_catalog.validate()
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_createMultipleCatalog.xml
0 → 100644
View file @
4a746445
<?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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5_createMultipleCatalog
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.py
0 → 100644
View file @
4a746445
portal
=
context
.
getPortalObject
()
portal_catalog
=
portal
.
portal_catalog
catalog_id_list
=
[]
connection_id_list
=
[]
deferred_connection_id_list
=
[]
for
i
in
range
(
164
,
200
):
catalog_id
=
'erp5_mysql_innodb%s'
%
i
catalog_id_list
.
append
(
catalog_id
)
connection_id
=
'erp5_sql_connection%s'
%
i
connection_id_list
.
append
(
connection_id
)
deferred_connection_id
=
'erp5_sql_deferred_connection%s'
%
i
deferred_connection_id_list
.
append
(
deferred_connection_id
)
portal
.
manage_delObjects
(
connection_id_list
)
portal
.
manage_delObjects
(
deferred_connection_id_list
)
portal_catalog
.
manage_delObjects
(
catalog_id_list
)
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_deleteMultipleCatalog.xml
0 → 100644
View file @
4a746445
<?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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5_deleteMultipleCatalog
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.py
0 → 100644
View file @
4a746445
portal
=
context
.
getPortalObject
()
for
i
in
range
(
101
,
164
):
connection_id
=
'erp5_sql_connection%s'
%
i
deferred_connection_id
=
'erp5_sql_deferred_connection%s'
%
i
connection_string
=
connection_string
=
'erp5_test_%(i)s@10.0.159.93:2099 testuser_%(i)s testpassword%(i)s'
%
{
'i'
:
i
}
getattr
(
portal
,
connection_id
).
connect
(
connection_string
)
getattr
(
portal
,
deferred_connection_id
).
connect
(
connection_string
)
product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/ERP5_restartDBConnection.xml
0 → 100644
View file @
4a746445
<?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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5_restartDBConnection
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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