Commit 336c3980 authored by Rafael Monnerat's avatar Rafael Monnerat

Update from upstream/master

parents ca6d28ec cd3d1baa
Pipeline #39248 passed with stage
in 0 seconds
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Alarm" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>active_sense_method_id</string> </key>
<value> <string>Alarm_checkSiteDailyModification</string> </value>
</item>
<item>
<key> <string>alarm_notification_mode</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>automatic_solve</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>check_site_daily_modification</string> </value>
</item>
<item>
<key> <string>periodicity_hour</string> </key>
<value>
<tuple>
<int>0</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_minute</string> </key>
<value>
<tuple>
<int>1</int>
</tuple>
</value>
</item>
<item>
<key> <string>periodicity_month</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_month_day</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>periodicity_start_date</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1603152000.0</float>
<string>GMT</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>periodicity_week</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Alarm</string> </value>
</item>
<item>
<key> <string>report_method_id</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Check Site Daily Modification</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
active_process = context.newActiveProcess().getRelativeUrl()
context.activate(tag=tag).Base_checkSiteDailyModification(active_process=active_process)
context.activate(after_tag=tag).getId()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>tag, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Alarm_checkSiteDailyModification</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from DateTime import DateTime
from Products.CMFActivity.ActiveResult import ActiveResult
from Products.ZSQLCatalog.SQLCatalog import Query
portal = context.getPortalObject()
if not check_date:
check_date = DateTime().earliestTime() - 1
active_process = context.restrictedTraverse(active_process)
for workflow_object in portal.portal_catalog(
portal_type=(
'Workflow',
'Workflow Script',
'Workflow State',
'Workflow Transition',
'Workflow Variable',
'Worklist',
'Interaction Workflow'
),
modification_date=Query(modification_date=check_date, range="min"),
select_list = ['relative_url']
):
active_process.postResult(ActiveResult(
severity=100,
detail='%s is modified' % workflow_object.relative_url))
for sub_path, sub_obj in portal.portal_skins.ZopeFind(portal.portal_skins, search_sub=1):
modified_date = DateTime(container.last_modified(sub_obj))
if modified_date >= check_date:
active_process.postResult(ActiveResult(
severity=100,
detail='%s is modified' % sub_path))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>active_process, check_date = None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_checkSiteDailyModification</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -30,6 +30,7 @@
import unittest
import time
from Products.ERP5.tests.testInventoryAPI import InventoryAPITestCase
from DateTime import DateTime
class TestERP5Administration(InventoryAPITestCase):
"""Test for erp5_administration business template.
......@@ -231,6 +232,51 @@ component_error()
location_and_message_list)
def test_check_site_modification(self):
# remove second, obj's modification in erp5 don't have seconds
check_date = DateTime(DateTime().strftime('%Y-%m-%d %H:%M'))
active_process = self.portal.portal_activities.newActiveProcess()
self.portal.Base_checkSiteDailyModification(
active_process=active_process.getRelativeUrl(),
check_date = check_date
)
result_list = [x.detail for x in active_process.getResultList()]
message_list = [
'erp5_administration/Base_checkSiteDailyModification is modified',
'erp5_administration/BusinessTemplate_viewCheckPythonCodeDialog is modified',
'portal_workflow/edit_workflow is modified',
'portal_workflow/edit_workflow/state_current is modified',
'portal_workflow/preference_interaction_workflow is modified'
]
for message in message_list:
self.assertNotIn(message, result_list)
self.portal.portal_skins.erp5_administration.Base_checkSiteDailyModification.ZPythonScript_setTitle('%s' % check_date)
self.portal.portal_skins.erp5_administration.Base_checkSiteDailyModification.ZPythonScript_setTitle('')
self.portal.portal_skins.erp5_administration.BusinessTemplate_viewCheckPythonCodeDialog.manage_addProduct['Formulator'].manage_addField('my_title', 'Title', 'StringField')
self.portal.portal_skins.erp5_administration.BusinessTemplate_viewCheckPythonCodeDialog.manage_delObjects('my_title')
new_comment = 'Test %s' % check_date
self.portal.portal_workflow.preference_interaction_workflow.edit(
comment = new_comment
)
self.portal.portal_workflow.edit_workflow.edit(
comment = new_comment
)
self.portal.portal_workflow.edit_workflow.state_current.edit(
comment = new_comment
)
self.tic()
self.portal.Base_checkSiteDailyModification(
active_process=active_process.getRelativeUrl(),
check_date = check_date
)
result_list = [x.detail for x in active_process.getResultList()]
for message in message_list:
self.assertIn(message, result_list)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestERP5Administration))
......
......@@ -4,5 +4,6 @@ portal_alarms/check_conversion_tool_availability
portal_alarms/check_folder_handler
portal_alarms/check_item_tracking
portal_alarms/check_localizer
portal_alarms/check_site_daily_modification
portal_alarms/check_skin_cache
portal_alarms/check_stock
\ No newline at end of file
<catalog_method>
<item key="sql_uncatalog_object" type="int">
<item key="sql_deferred_uncatalog_object" type="int">
<value>1</value>
</item>
</catalog_method>
DELETE FROM content_translation WHERE <dtml-sqltest uid op=eq type=int>
\ No newline at end of file
DELETE FROM content_translation WHERE <dtml-sqltest uid op=eq type=int multiple>
\ No newline at end of file
<catalog_method>
<item key="sql_catalog_object_list" type="int">
<item key="sql_deferred_catalog_object_list" type="int">
<value>1</value>
</item>
</catalog_method>
......@@ -134,8 +134,11 @@ class TestCopySupport(ERP5TypeTestCase):
self.tic()
finally:
ActivityTool.invokeGroup = ActivityTool_invokeGroup
self.assertEqual(invokeGroup_list,
['portal_catalog/uncatalogObjectList', uid_list, 'SQLQueue', False])
catalog_relative_url = self.portal.portal_catalog.getSQLCatalog().getRelativeUrl()
self.assertEqual(invokeGroup_list, [
'portal_catalog/uncatalogObjectList', uid_list, 'SQLQueue', False,
catalog_relative_url + '/SQLCatalog_deferUncatalogObjectActivity', uid_list, 'SQLQueue', False,
])
self.assertEqual(len(search_catalog(uid=uid_list)), 0)
......
# This script is called to defer fulltext indexing.
METHOD_ID = script.id + 'Activity'
GROUP_METHOD_ID = context.getPath() + '/' + METHOD_ID
GROUP_METHOD_ID = 'portal_catalog/deferredCatalogObjectList'
activateObject = context.getPortalObject().portal_activities.activateObject
try:
priority = context.getActivityRuntimeEnvironment().getPriority()
......@@ -26,4 +26,4 @@ for document in getPath:
serialization_tag='full_text_' + document,
),
METHOD_ID,
)()
)(check_uid=0, deferred=1)
from Products.ERP5Type.Utils import UpperCase
from ZODB.POSException import ConflictError
from zExceptions import Unauthorized
import six
method = context.z_catalog_fulltext_list
property_list = method.arguments_src.split()
parameter_dict = {x: [] for x in property_list}
# BBB only used when upgrading that still spawn activities with this method id.
for group_object in object_list:
tmp_dict = {}
try:
obj = group_object.object
for property in property_list:
getter = getattr(obj, property, None)
if callable(getter):
value = getter()
else:
value = getattr(obj, 'get%s' % UpperCase(property))()
tmp_dict[property] = value
except ConflictError:
raise
except Unauthorized: # should happen in tricky testERP5Catalog tests only
# Fake activity success: if indexation cannot View document, ignore it.
group_object.result = None
except Exception:
group_object.raised()
else:
for property, value in six.iteritems(tmp_dict):
parameter_dict[property].append(value)
group_object.result = None
if parameter_dict:
return method(**parameter_dict)
group_object.object.reindexObject()
group_object.result = None
......@@ -52,14 +52,6 @@
<key> <string>_params</string> </key>
<value> <string>object_list</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
......
<catalog_method>
<item key="sql_uncatalog_object" type="int">
<value>1</value>
</item>
</catalog_method>
# This script is called to defer fulltext unindexing.
METHOD_ID = script.id + 'Activity'
GROUP_METHOD_ID = context.getRelativeUrl() + '/' + METHOD_ID
try:
priority = context.getActivityRuntimeEnvironment().getPriority()
except KeyError:
# called outside of an activity, could be an immediate reindexation
# XXX: duplicates default priority for sake of simplicity and speed.
# Strictly, this could also look-up default activate parameters, but on
# which document ? Traversing is expensive. So keep things fast by default.
priority = 1
# Optimise cache usage by reducing the likelyhood of a processing node
# including activities spawned by others into its activity group.
# Use unindexObject as dummy method id for compatibility with
# after_method_id=('unindexObject', ...)
context.activate(
activity='SQLQueue',
priority=priority,
node='same',
group_method_id=GROUP_METHOD_ID,
).unindexObject(uid=uid)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Python Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>uid</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SQLCatalog_deferUncatalogObject</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Python Script</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
uid_list = []
for grouped_message in grouped_message_list:
assert not grouped_message.args
assert grouped_message.kw.keys() == ['uid']
uid_list.append(grouped_message.kw['uid'])
for method_id in context.getSqlDeferredUncatalogObjectList():
method = getattr(context, method_id)
method(uid=uid_list)
for grouped_message in grouped_message_list:
grouped_message.result = None
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Python Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>grouped_message_list</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SQLCatalog_deferUncatalogObjectActivity</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Python Script</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
DELETE FROM catalog_full_text WHERE <dtml-sqltest uid op=eq type=int>
\ No newline at end of file
DELETE FROM catalog_full_text WHERE <dtml-sqltest uid op=eq type=int multiple>
\ No newline at end of file
<catalog_method>
<item key="sql_uncatalog_object" type="int">
<item key="sql_deferred_uncatalog_object" type="int">
<value>1</value>
</item>
</catalog_method>
DELETE FROM full_text WHERE <dtml-sqltest uid op=eq type=int>
\ No newline at end of file
DELETE FROM full_text WHERE <dtml-sqltest uid op=eq type=int multiple>
\ No newline at end of file
<catalog_method>
<item key="sql_deferred_catalog_object_list" type="int">
<value>1</value>
</item>
</catalog_method>
erp5_mysql_innodb/SQLCatalog_deferFullTextIndex
erp5_mysql_innodb/SQLCatalog_deferFullTextIndexActivity
erp5_mysql_innodb/SQLCatalog_deferUncatalogObject
erp5_mysql_innodb/SQLCatalog_deferUncatalogObjectActivity
erp5_mysql_innodb/SQLCatalog_makeFullTextQuery
erp5_mysql_innodb/z0_drop_catalog_fulltext
erp5_mysql_innodb/z0_drop_content_translation
......
......@@ -29,6 +29,8 @@ def filterActions(actions):
filtered_actions[action_category_name].extend(action_list)
else:
filtered_actions[action_category_name] = action_list
if filter_action_script_id:
filtered_actions = getattr(context, filter_action_script_id)(filtered_actions)
return {action_category_name: sorted(action_list, key=lambda x: x.get('priority', 1.0))
for action_category_name, action_list in filtered_actions.items()}
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>actions</string> </value>
<value> <string>actions, filter_action_script_id=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -1472,8 +1472,12 @@ def calculateHateoas(is_portal=None, is_site_root=None, traversed_document=None,
}
# Find current action URL and extract embedded view
filter_action_script_id = ''
if hasattr(site_root, 'getLayoutProperty'):
filter_action_script_id = site_root.getLayoutProperty('configuration_filter_action_script_id', default='')
erp5_action_dict = portal.Base_filterDuplicateActions(
portal.portal_actions.listFilteredActionsFor(traversed_document))
portal.portal_actions.listFilteredActionsFor(traversed_document),
filter_action_script_id)
for erp5_action_key in erp5_action_dict.keys():
for view_action in erp5_action_dict[erp5_action_key]:
# Try to embed the form in the result
......
......@@ -78,6 +78,7 @@
<list>
<string>my_configuration_login</string>
<string>my_configuration_logout</string>
<string>my_configuration_filter_action_script_id</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_configuration_filter_action_script_id</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_reference</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Filter Action Script Id</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -709,6 +709,61 @@ class TestERP5Document_getHateoas_mode_traverse(ERP5HALJSONStyleSkinsMixin):
document.getRelativeUrl()))
self.assertEqual(result_dict['_embedded']['_view']['_actions']['put']['method'], 'POST')
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
'return "application/hal+json"')
@simulate('Base_filterActionId', 'actions', """
filtered_actions = {}
for action_category_name, action_list in actions.items():
filtered_actions[action_category_name] = [action for action in action_list if 'foo' in action['id']]
return filtered_actions
""")
@changeSkin('Hal')
def test_getHateoasDocument_filtered_view(self):
self.portal.web_site_module.hateoas.edit(configuration_filter_action_script_id='Base_filterActionId')
document = self._makeDocument()
document.Foo_view.listbox.ListBox_setPropertyList(
field_title='Foo Lines',
field_list_method='objectValues',
field_portal_types='Foo Line | Foo Line',
field_stat_method='portal_catalog',
field_stat_columns='quantity | Foo_statQuantity',
field_editable=1,
field_columns='id|ID\ntitle|Title\nquantity|Quantity\nstart_date|Date\ncatalog.uid|Uid',
field_editable_columns='id|ID\ntitle|Title\nquantity|quantity\nstart_date|Date',
field_search_columns='id|ID\ntitle|Title\nquantity|Quantity\nstart_date|Date',
field_domain_root_list='foo_category|FooCat\nfoo_domain|FooDomain\nnot_existing_domain|NotExisting',)
parent = document.getParentValue()
fake_request = do_fake_request("GET")
result = self.portal.web_site_module.hateoas.ERP5Document_getHateoas(REQUEST=fake_request, mode="traverse", relative_url=document.getRelativeUrl(), view="view")
self.assertEqual(fake_request.RESPONSE.status, 200)
self.assertEqual(fake_request.RESPONSE.getHeader('Content-Type'),
"application/hal+json"
)
result_dict = json.loads(result)
self.assertEqual(result_dict['_links']['self'], {"href": "http://example.org/bar"})
self.assertEqual(result_dict['_links']['parent'],
{"href": "urn:jio:get:%s" % parent.getRelativeUrl(), "name": parent.getTitle()})
self.assertEqual(result_dict['_links']['view']['href'],
"%s/web_site_module/hateoas/ERP5Document_getHateoas?mode=traverse&relative_url=%s&view=view_formbox_fooline" % (
self.portal.absolute_url(),
quote_plus(document.getRelativeUrl())))
self.assertEqual(result_dict['_links']['view']['title'], "FormBox FooLine")
self.assertEqual(result_dict['_links']['view']['name'], "view_formbox_fooline")
self.assertNotIn('_embedded', result_dict)
for category, value in result_dict['_links'].items():
if 'action' in category:
if isinstance(value, dict):
self.assertIn('foo', value['name'])
else:
for link in value:
self.assertIn('foo', link['name'])
@simulate('Base_getRequestUrl', '*args, **kwargs',
'return "http://example.org/bar"')
@simulate('Base_getRequestHeader', '*args, **kwargs',
......
......@@ -46,13 +46,13 @@ class MailevaSOAPConnector(XMLObject):
security.declareObjectProtected(Permissions.AccessContentsInformation)
# Default Properties
property_sheets = ( PropertySheet.Base
property_sheets = (PropertySheet.Base
, PropertySheet.XMLObject
, PropertySheet.CategoryCore
)
)
def processResponse(self, response, maileva_exchange, failed=False):
maileva_exchange.edit(
response = response
response=response
)
maileva_exchange.confirm()
# change state, no need to wait alarm check
......@@ -61,28 +61,29 @@ class MailevaSOAPConnector(XMLObject):
maileva_exchange.getFollowUpValue().fail()
def submitRequest(self, maileva_exchange):
authenticated = HttpAuthenticated(username=self.getUserId(), password=self.getPassword())
authenticated = HttpAuthenticated(username=self.getUserId(),
password=self.getPassword())
runtime_environment = self.getActivityRuntimeEnvironment()
if runtime_environment:
runtime_environment.edit(
conflict_retry=False,
max_retry=0)
try:
response = suds.client.Client(url = self.getProperty('submit_url_string'), transport=authenticated).service.submit(__inject={'msg': maileva_exchange.getRequest()})
response = suds.client.Client(
url=self.getSubmitLinkUrlString(),
transport=authenticated
).service.submit(__inject={'msg': maileva_exchange.getRequest()})
maileva_exchange.activate().MailevaExchange_processResponse(response)
except socket.error as e:
if e.errno == socket.errno.ECONNREFUSED:
if runtime_environment:
runtime_environment.edit(max_retry=None)
except Exception as e:
maileva_exchange.activate().MailevaExchange_processResponse(str(e), failed = True)
maileva_exchange.activate().MailevaExchange_processResponse(str(e), failed=True)
def checkPendingNotifications(self):
authenticated = HttpAuthenticated(username=self.getUserId(), password=self.getPassword())
client = suds.client.Client(url = self.getProperty("tracking_url_string"), transport=authenticated)
client = suds.client.Client(url=self.getTrackingLinkUrlString(), transport=authenticated)
notification_dict = {}
for notification in client.service.checkPendingNotifications("GENERAL"):
notification_dict[notification.reqTrackId] = {
......@@ -95,7 +96,8 @@ class MailevaSOAPConnector(XMLObject):
def getPendingNotificationDetails(self, request_id, debug=False):
authenticated = HttpAuthenticated(username=self.getUserId(), password=self.getPassword())
result = suds.client.Client(url = self.getProperty("tracking_url_string"), transport=authenticated).service.getPendingNotificationDetails(request_id)
result = suds.client.Client(url=self.getTrackingLinkUrlString(),
transport=authenticated).service.getPendingNotificationDetails(request_id)
return {
"status": str(result.status),
"notification_status": str(result.notificationStatus),
......
......@@ -7,6 +7,7 @@
</portal_type>
<portal_type id="Maileva SOAP Connector">
<item>Login</item>
<item>MailevaSOAPConnector</item>
<item>Reference</item>
<item>Url</item>
</portal_type>
......
......@@ -38,6 +38,12 @@
<key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>MailevaSOAPConnector</string> </value>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>MailevaSOAPConnector</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Content Existence Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_portal_type</string> </key>
<value> <string>python: (\'Link\',)</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>link_existence_constraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Content Existence Constraint</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="String Attribute Match Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>message_property_not_set</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<value>
<tuple>
<string>password</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>password_constraint</string> </value>
</item>
<item>
<key> <string>message_attribute_not_match</string> </key>
<value> <string>password has to be set.</string> </value>
</item>
<item>
<key> <string>message_no_such_property</string> </key>
<value> <string>password has to be set.</string> </value>
</item>
<item>
<key> <string>message_property_not_set</string> </key>
<value> <string>Certificate has to be set.</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>String Attribute Match Constraint</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Acquired 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>acquisition_base_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>acquisition_object_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>alt_accessor_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/content</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_acquired_property_id</string> </key>
<value>
<tuple>
<string>url_string</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_portal_type</string> </key>
<value> <string>python: (\'Link\',)</string> </value>
</item>
<item>
<key> <string>content_translation_acquired_property_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Include link URL</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>submit_link_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>Acquired Property</string> </value>
</item>
<item>
<key> <string>storage_id</string> </key>
<value> <string>submit_link</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="String Attribute Match Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>message_property_not_set</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<value>
<tuple>
<string>submit_link_url_string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>submit_link_url_string_constraint</string> </value>
</item>
<item>
<key> <string>message_attribute_not_match</string> </key>
<value> <string>Submit URL have to be set</string> </value>
</item>
<item>
<key> <string>message_no_such_property</string> </key>
<value> <string>Submit URL have to be set</string> </value>
</item>
<item>
<key> <string>message_property_not_set</string> </key>
<value> <string>Payzen URL have to be set</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>String Attribute Match Constraint</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Acquired 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>acquisition_base_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>acquisition_object_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>alt_accessor_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/content</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_acquired_property_id</string> </key>
<value>
<tuple>
<string>url_string</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_portal_type</string> </key>
<value> <string>python: (\'Link\',)</string> </value>
</item>
<item>
<key> <string>content_translation_acquired_property_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Link for tracking url</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>tracking_link_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>Acquired Property</string> </value>
</item>
<item>
<key> <string>storage_id</string> </key>
<value> <string>tracking_link</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="String Attribute Match Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>message_property_not_set</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<value>
<tuple>
<string>tracking_link_url_string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>tracking_link_url_string_constraint</string> </value>
</item>
<item>
<key> <string>message_attribute_not_match</string> </key>
<value> <string>Tracking URL have to be set</string> </value>
</item>
<item>
<key> <string>message_no_such_property</string> </key>
<value> <string>Tracking URL have to be set</string> </value>
</item>
<item>
<key> <string>message_property_not_set</string> </key>
<value> <string>Payzen URL have to be set</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>String Attribute Match Constraint</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="String Attribute Match Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>message_property_not_set</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<value>
<tuple>
<string>user_id</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>user_id_constraint</string> </value>
</item>
<item>
<key> <string>message_attribute_not_match</string> </key>
<value> <string>User ID have to be set</string> </value>
</item>
<item>
<key> <string>message_no_such_property</string> </key>
<value> <string>User ID have to be set</string> </value>
</item>
<item>
<key> <string>message_property_not_set</string> </key>
<value> <string>vads_site_id have to be set</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>String Attribute Match Constraint</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
maileva_connector = context.portal_catalog.getResultValue(
maileva_connector_list = context.portal_catalog(
portal_type='Maileva SOAP Connector',
reference=reference,
validation_state='validated')
if not maileva_connector:
raise ValueError('Maileav soap connector is not defined')
return maileva_connector
validation_state='validated',
limit=2)
# Ensure there is no duplication.
if not len(maileva_connector_list):
raise ValueError('Maileva soap connector is not defined')
elif len(maileva_connector_list) != 1:
raise ValueError('More them one Maileva soap connector was found!')
return maileva_connector_list[0]
......@@ -115,8 +115,8 @@
<key> <string>right</string> </key>
<value>
<list>
<string>my_submit_url_string</string>
<string>my_tracking_url_string</string>
<string>my_submit_link_url_string</string>
<string>my_tracking_link_url_string</string>
<string>my_translated_validation_state_title</string>
</list>
</value>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_submit_url_string</string> </value>
<value> <string>my_submit_link_url_string</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
......@@ -16,7 +16,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_tracking_url_string</string> </value>
<value> <string>my_tracking_link_url_string</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......
translateString = context.Base_translateString
if context.getSendState() != 'failed':
return context.Base_redirect('Document_viewMailevaConnectionStatus', keep_items={'portal_status_message': 'This document is not in failed state'})
return context.Base_redirect('Document_viewMailevaConnectionStatus',
keep_items={'portal_status_message': translateString('This document is not in failed state')})
maileva_exchange = context.getFollowUpRelatedValue(portal_type='Maileva Exchange')
context.PDF_sendToMaileva(
recipient = maileva_exchange.getDestinationValue(),
sender = maileva_exchange.getSourceValue()
)
return context.Base_redirect('PDF_viewPDFJSPreview', keep_items={'portal_status_message': 'This document is resending to maileva'})
return context.Base_redirect('PDF_viewPDFJSPreview',
keep_items={'portal_status_message': translateString('This document is resending to maileva')})
......@@ -3,5 +3,6 @@ Maileva Exchange | Arrow
Maileva Exchange | Event
Maileva Exchange | HttpExchange
Maileva SOAP Connector | Login
Maileva SOAP Connector | MailevaSOAPConnector
Maileva SOAP Connector | Reference
Maileva SOAP Connector | Url
\ No newline at end of file
MailevaSOAPConnector
\ No newline at end of file
<?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>select_variable</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<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/multiple selection</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Methods to be called to catalog the list of objects with a deferred connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>sql_deferred_catalog_object_list_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>
<item>
<key> <string>select_variable</string> </key>
<value> <string>getCatalogMethodIds</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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/multiple selection</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Methods to be called to uncatalog an object with a deferred connection</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>sql_deferred_uncatalog_object_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>
<item>
<key> <string>select_variable</string> </key>
<value> <string>getCatalogMethodIds</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -118,7 +118,9 @@
<value>
<list>
<string>my_sql_catalog_object_list_list</string>
<string>my_sql_deferred_catalog_object_list_list</string>
<string>my_sql_uncatalog_object_list</string>
<string>my_sql_deferred_uncatalog_object_list</string>
<string>my_sql_search_tables_list</string>
<string>my_sql_catalog_datetime_search_keys_list</string>
</list>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_sql_deferred_catalog_object_list_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_multi_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Deferred Catalog Objects</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:[(\'\', \'\')]+here.getCatalogMethodIds()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>items</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_sql_deferred_uncatalog_object_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_multi_list_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Deferred Uncatalog Object</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:[(\'\', \'\')]+here.getCatalogMethodIds()</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -889,10 +889,15 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
"""
return ZCatalog.countResults(self, REQUEST, **kw)
def wrapObjectList(self, object_value_list, catalog_value):
def wrapObjectList(self, object_value_list, catalog_value, deferred=False):
"""
Return a list of wrapped objects for reindexing.
"""
if deferred:
# No need to wrap, but should return a list
if isinstance(object_value_list, set):
object_value_list = list(object_value_list)
return object_value_list
portal = self.getPortalObject()
user_set = set()
......@@ -973,7 +978,7 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
security.declarePrivate('reindexObject')
reindexObject = reindexCatalogObject
security.declarePrivate('catalogObjectList')
def catalogObjectList(self, object_list, *args, **kw):
"""Catalog a list of objects"""
m = object_list[0]
......@@ -990,6 +995,9 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
else:
super(CatalogTool, self).catalogObjectList(object_list, *args, **kw)
security.declarePrivate('deferredCatalogObjectList')
deferredCatalogObjectList = catalogObjectList
security.declarePrivate('uncatalogObjectList')
def uncatalogObjectList(self, message_list):
"""Uncatalog a list of objects"""
......
......@@ -29,7 +29,6 @@ from OFS.Folder import Folder
from AccessControl import ClassSecurityInfo
from AccessControl.Permissions import (
access_contents_information,
import_export_objects,
manage_zcatalog_entries,
)
from AccessControl.SimpleObjectPolicies import ContainerAssertions
......@@ -54,10 +53,6 @@ import pprint
import re
import warnings
from contextlib import contextmanager
from xml.dom.minidom import parse
from xml.sax.saxutils import escape, quoteattr
import os
from hashlib import md5
from .interfaces.query_catalog import ISearchKeyCatalog
from zope.interface.verify import verifyClass
......@@ -402,11 +397,21 @@ class Catalog(Folder,
'type' : 'multiple selection',
'select_variable' : 'getCatalogMethodIds',
'mode' : 'w' },
{ 'id' : 'sql_deferred_catalog_object_list',
'description' : 'Methods to be called to catalog the list of objects with a deferred connection',
'type' : 'multiple selection',
'select_variable' : 'getCatalogMethodIds',
'mode' : 'w' },
{ 'id' : 'sql_uncatalog_object',
'description' : 'Methods to be called to uncatalog an object',
'type' : 'multiple selection',
'select_variable' : 'getCatalogMethodIds',
'mode' : 'w' },
{ 'id' : 'sql_deferred_uncatalog_object',
'description' : 'Methods to be called to uncatalog an object with a deferred connection',
'type' : 'multiple selection',
'select_variable' : 'getCatalogMethodIds',
'mode' : 'w' },
{ 'id' : 'sql_catalog_translation_list',
'description' : 'Methods to be called to catalog the list of translation objects',
'type' : 'selection',
......@@ -587,7 +592,9 @@ class Catalog(Folder,
sql_catalog_delete_uid = ''
sql_catalog_clear_reserved = ''
sql_catalog_object_list = ()
sql_deferred_catalog_object_list = ()
sql_uncatalog_object = ()
sql_deferred_uncatalog_object = ()
sql_clear_catalog = ()
sql_catalog_translation_list = ''
sql_delete_translation_list = ''
......@@ -1217,11 +1224,10 @@ class Catalog(Folder,
elapse = time.time()
c_elapse = time.clock()
words = 0
obj = REQUEST.PARENTS[1]
path = '/'.join(obj.getPhysicalPath())
results = self.aq_parent.ZopeFindAndApply(obj,
self.aq_parent.ZopeFindAndApply(obj,
obj_metatypes=obj_metatypes,
obj_ids=obj_ids,
obj_searchterm=obj_searchterm,
......@@ -1252,7 +1258,7 @@ class Catalog(Folder,
security.declarePrivate('catalogObjectList')
def catalogObjectList(self, object_list, method_id_list=None,
disable_cache=0, check_uid=1, idxs=None):
disable_cache=0, check_uid=1, idxs=None, deferred=0):
"""Add objects to the Catalog by calling all SQL methods and
providing needed arguments.
......@@ -1276,13 +1282,17 @@ class Catalog(Folder,
method_id_list=method_id_list,
disable_cache=disable_cache,
check_uid=check_uid,
idxs=idxs)
idxs=idxs,
deferred=deferred)
def getSqlCatalogObjectListList(self):
return self.sql_catalog_object_list
def getSqlDeferredCatalogObjectListList(self):
return self.sql_deferred_catalog_object_list
def _catalogObjectList(self, object_list, method_id_list=None,
disable_cache=0, check_uid=1, idxs=None):
disable_cache=0, check_uid=1, idxs=None, deferred=0):
"""This is the real method to catalog objects."""
if idxs not in (None, []):
LOG('ZSLQCatalog.SQLCatalog:catalogObjectList', WARNING,
......@@ -1349,7 +1359,10 @@ class Catalog(Folder,
LOG('SQLCatalog._catalogObjectList', ERROR, error_message)
if method_id_list is None:
method_id_list = self.getSqlCatalogObjectListList()
if deferred:
method_id_list = self.getSqlDeferredCatalogObjectListList()
else:
method_id_list = self.getSqlCatalogObjectListList()
econtext = getEngine().getContext()
if disable_cache:
argument_cache = DummyDict()
......@@ -1496,6 +1509,9 @@ class Catalog(Folder,
def getSqlUncatalogObjectList(self):
return self.sql_uncatalog_object
def getSqlDeferredUncatalogObjectList(self):
return self.sql_deferred_uncatalog_object
security.declarePrivate('uncatalogObject')
def uncatalogObject(self, path=None, uid=None):
"""
......@@ -1874,9 +1890,7 @@ class Catalog(Folder,
"""
search_key, related_key_definition = self.getColumnSearchKey(key,
search_key_name=search_key_name)
if search_key is None:
result = None
else:
if search_key is not None:
if related_key_definition is not None:
search_key = search_key.getSearchKey(sql_catalog=self,
related_key_definition=related_key_definition,
......@@ -2450,30 +2464,12 @@ class Catalog(Folder,
if method.meta_type in ('Z SQL Method', 'ERP5 SQL Method') and ('deferred' in method.connection_id) == deferred:
return method.connection_id
def getSqlCatalogObjectList(self):
try:
return self.sql_catalog_object
except AttributeError:
return ()
def getSqlUncatalogObjectList(self):
try:
return self.sql_uncatalog_object
except AttributeError:
return ()
def getSqlUpdateObjectList(self):
try:
return self.sql_update_object
except AttributeError:
return ()
def getSqlCatalogObjectListList(self):
try:
return self.sql_catalog_object_list
except AttributeError:
return ()
security.declarePrivate('getFilterableMethodList')
def getFilterableMethodList(self):
"""
......@@ -2482,10 +2478,11 @@ class Catalog(Folder,
method_id_set = set()
if withCMF:
method_id_set.update(
self.getSqlCatalogObjectList() +
self.getSqlCatalogObjectListList() +
self.getSqlDeferredCatalogObjectListList() +
self.getSqlUncatalogObjectList() +
self.getSqlUpdateObjectList() +
self.getSqlCatalogObjectListList()
self.getSqlDeferredUncatalogObjectList() +
self.getSqlUpdateObjectList()
)
return [
method
......
......@@ -671,7 +671,7 @@ class ZCatalog(Folder, Persistent, Implicit):
return []
security.declarePrivate('wrapObjectList')
def wrapObjectList(self, object_value_list, catalog_value):
def wrapObjectList(self, object_value_list, catalog_value, deferred=False):
"""
Return a list of wrapped objects for reindexing.
......@@ -690,6 +690,7 @@ class ZCatalog(Folder, Persistent, Implicit):
"""Catalog a list of objects.
"""
catalog = self.getSQLCatalog(sql_catalog_id)
deferred = kw.get('deferred', False)
hot_reindexing = (self.hot_reindexing_state is not None) and \
(catalog is not None) and \
(self.source_sql_catalog_id == catalog.id)
......@@ -791,6 +792,7 @@ class ZCatalog(Folder, Persistent, Implicit):
self.wrapObjectList(
object_value_list=d['obj'],
catalog_value=destination_catalog,
deferred=deferred,
),
**kw
)
......@@ -801,6 +803,7 @@ class ZCatalog(Folder, Persistent, Implicit):
self.wrapObjectList(
object_value_list=d['obj'],
catalog_value=archive_catalog,
deferred=deferred,
),
**kw
)
......@@ -815,6 +818,7 @@ class ZCatalog(Folder, Persistent, Implicit):
self.wrapObjectList(
object_value_list=current_catalog_object_list,
catalog_value=catalog,
deferred=deferred,
),
**kw
)
......@@ -828,6 +832,7 @@ class ZCatalog(Folder, Persistent, Implicit):
self.wrapObjectList(
object_value_list=object_set,
catalog_value=destination_catalog,
deferred=deferred,
),
**kw
)
......
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