Commit 5165ac8a authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

erp5_archive: add READ-COMMITTED connection.

parent d95690fc
......@@ -27,6 +27,7 @@
#
##############################################################################
import re
import time
import unittest
......@@ -176,6 +177,13 @@ class TestArchive(InventoryAPITestCase):
addSQLConnection(self.new_connection_id,'', db1)
new_connection = portal[self.new_connection_id]
new_connection.manage_open_connection()
# the READ-COMMITTED one
self.new_read_committed_connection_id = 'erp5_sql_read_committed_connection1'
addSQLConnection(self.new_read_committed_connection_id, '',
re.sub(
r'((?:[%*][^ ]+ )*)(![^ ]+ )?(.+)', r'\1!READ-COMMITTED \3', db1))
new_connection = portal[self.new_read_committed_connection_id]
new_connection.manage_open_connection()
# the deferred one
self.new_deferred_connection_id = 'erp5_sql_connection2'
addSQLConnection(self.new_deferred_connection_id,'', db1)
......@@ -187,6 +195,13 @@ class TestArchive(InventoryAPITestCase):
addSQLConnection(self.archive_connection_id,'', db2)
archive_connection = portal[self.archive_connection_id]
archive_connection.manage_open_connection()
# the READ-COMMITTED one
self.archive_read_committed_connection_id = 'erp5_sql_read_committed_connection3'
addSQLConnection(self.archive_read_committed_connection_id, '',
re.sub(
r'((?:[%*][^ ]+ )*)(![^ ]+ )?(.+)', r'\1!READ-COMMITTED \3', db2))
archive_connection = portal[self.archive_read_committed_connection_id]
archive_connection.manage_open_connection()
# the deferred one
self.archive_deferred_connection_id = 'erp5_sql_connection4'
addSQLConnection(self.archive_deferred_connection_id,'', db2)
......@@ -212,6 +227,7 @@ class TestArchive(InventoryAPITestCase):
archive = portal_archive.newContent(portal_type="Archive",
catalog_id=self.archive_catalog_id,
connection_id=self.archive_connection_id,
read_committed_connection_id=self.archive_read_committed_connection_id,
deferred_connection_id=self.archive_deferred_connection_id,
priority=3,
inventory_method_id='Archive_createAllInventory',
......@@ -224,6 +240,7 @@ class TestArchive(InventoryAPITestCase):
dest = portal_archive.newContent(portal_type="Archive",
catalog_id=self.new_catalog_id,
connection_id=self.new_connection_id,
read_committed_connection_id=self.new_read_committed_connection_id,
deferred_connection_id=self.new_deferred_connection_id,
priority=1,
test_method_id='Archive_test',
......
......@@ -123,9 +123,10 @@ class ArchiveTool(BaseTool):
source_catalog_id = source_catalog.getId()
source_connection_id = source_catalog.getConnectionId()
source_read_committed_connection_id = source_catalog.getConnectionId(read_committed=True)
source_deferred_connection_id = source_catalog.getConnectionId(deferred=True)
if source_connection_id is None or source_deferred_connection_id is None:
if source_connection_id is None or source_read_committed_connection_id is None or source_deferred_connection_id is None:
raise ValueError("Unable to determine connection id for the current catalog")
# Get destination property from archive
......@@ -133,6 +134,7 @@ class ArchiveTool(BaseTool):
destination_archive = self._getOb(destination_archive_id)
destination_sql_catalog_id = destination_archive.getCatalogId()
destination_connection_id = destination_archive.getConnectionId()
destination_read_committed_connection_id = destination_archive.getReadCommittedConnectionId()
destination_deferred_connection_id = destination_archive.getDeferredConnectionId()
# Get archive property from archive
......@@ -140,6 +142,7 @@ class ArchiveTool(BaseTool):
archive = self._getOb(archive_id)
archive_sql_catalog_id = archive.getCatalogId()
archive_connection_id = archive.getConnectionId()
archive_read_committed_connection_id = archive.getReadCommittedConnectionId()
archive_deferred_connection_id = archive.getDeferredConnectionId()
# Check we don't use same connection id for source and destination
......@@ -147,6 +150,8 @@ class ArchiveTool(BaseTool):
raise ValueError("Destination and source catalog can't be the same")
if destination_connection_id == source_connection_id:
raise ValueError("Destination and source connection can't be the same")
if destination_read_committed_connection_id == source_read_committed_connection_id:
raise ValueError("Destination and source READ-COMMITTED connection can't be the same")
if destination_deferred_connection_id == source_deferred_connection_id:
raise ValueError("Destination and source deferred connection can't be the same")
# Same for source and archive
......@@ -154,6 +159,8 @@ class ArchiveTool(BaseTool):
raise ValueError("Archive and source catalog can't be the same")
if archive_connection_id == source_connection_id:
raise ValueError("Archive and source connection can't be the same")
if archive_read_committed_connection_id == source_read_committed_connection_id:
raise ValueError("Archive and source READ-COMMITTED connection can't be the same")
if archive_deferred_connection_id == source_deferred_connection_id:
raise ValueError("Archive and source deferred connection can't be the same")
# Same for destination and archive
......@@ -161,6 +168,8 @@ class ArchiveTool(BaseTool):
raise ValueError("Archive and destination catalog can't be the same")
if archive_connection_id == destination_connection_id:
raise ValueError("Archive and destination connection can't be the same")
if archive_read_committed_connection_id == destination_read_committed_connection_id:
raise ValueError("Archive and destination READ-COMMITED connection can't be the same")
if archive_deferred_connection_id == destination_deferred_connection_id:
raise ValueError("Archive and destination deferred connection can't be the same")
......@@ -168,6 +177,7 @@ class ArchiveTool(BaseTool):
destination_sql_catalog = getattr(portal_catalog, destination_sql_catalog_id)
if update_destination_sql_catalog:
sql_connection_id_dict = {source_connection_id : destination_connection_id,
source_read_committed_connection_id : destination_read_committed_connection_id,
source_deferred_connection_id : destination_deferred_connection_id}
portal_catalog.changeSQLConnectionIds(destination_sql_catalog,
sql_connection_id_dict)
......@@ -175,6 +185,7 @@ class ArchiveTool(BaseTool):
archive_sql_catalog = getattr(portal_catalog, archive_sql_catalog_id)
if update_archive_sql_catalog:
sql_connection_id_dict = {source_connection_id : archive_connection_id,
source_read_committed_connection_id : archive_read_committed_connection_id,
source_deferred_connection_id : archive_deferred_connection_id}
portal_catalog.changeSQLConnectionIds(archive_sql_catalog,
sql_connection_id_dict)
......@@ -194,8 +205,10 @@ class ArchiveTool(BaseTool):
destination_sql_catalog_id=destination_sql_catalog_id,
archive_path=archive.getPath(),
source_sql_connection_id_list=[source_connection_id, \
source_read_committed_connection_id,
source_deferred_connection_id],
destination_sql_connection_id_list=[destination_connection_id, \
destination_read_committed_connection_id,
destination_deferred_connection_id],
REQUEST=REQUEST, RESPONSE=RESPONSE)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The id of the READ-COMMITTED connection used by the archive</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>read_committed_connection_id_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string>w</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment