Commit 2f8a1d71 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Initial version of metadata discovery for ingestion of email events in CRM.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16993 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d25db6c9
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
"""\n
This script is called during the metadata discovery process\n
for each event which has been ingested through the email interface\n
by portal contributions. It tries to analyse the text content \n
to define the different event parameters.\n
\n
This version provides only early support.\n
\n
TODO:\n
- support forwarded messages\n
- support incoming / outgoing messages (in releation with \n
Event_finishIngestion)\n
"""\n
\n
def getPersonList(information_text):\n
result = []\n
for recipient in information_text.split(\',\'):\n
if "<" in recipient:\n
recipient = recipient[recipient.find(\'<\') + 1:]\n
recipient = recipient[:recipient.find(\'>\')]\n
if recipient:\n
email = context.portal_catalog.getResultValue(url_string=recipient, portal_type="Email")\n
if email is not None:\n
result.append(email.getParentValue().getRelativeUrl())\n
return result\n
\n
content_information = context.getContentInformation()\n
sender_list = getPersonList(content_information.get(\'From\', \'\'))\n
to_list = getPersonList(content_information.get(\'To\', \'\'))\n
cc_list = getPersonList(content_information.get(\'CC\', \'\'))\n
\n
# Build references\n
reference_search_list = []\n
text_search_list = []\n
for text, prop_dict in context.getSearchableReferenceList():\n
if text: text_search_list.append(text)\n
if prop_dict.has_key(\'reference\'): reference_search_list.append(prop_dict[\'reference\'])\n
\n
# Search reference ticket or project\n
follow_up_type_list = context.getPortalProjectTypeList() + context.getPortalTicketTypeList()\n
print follow_up_type_list\n
follow_up = context.portal_catalog.getResultValue(reference=reference_search_list, portal_type=follow_up_type_list)\n
if follow_up is None:\n
follow_up = context.portal_catalog.getResultValue(reference=text_search_list, portal_type=follow_up_type_list)\n
\n
# Build dict.\n
result = {}\n
if sender_list: result[\'source_list\'] = sender_list\n
if to_list or cc_list: result[\'destination_list\'] = to_list + cc_list\n
if follow_up is not None: result[\'follow_up\'] = follow_up.getRelativeUrl()\n
\n
return result\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>_print_</string>
<string>_print</string>
<string>getPersonList</string>
<string>_getattr_</string>
<string>context</string>
<string>content_information</string>
<string>sender_list</string>
<string>to_list</string>
<string>cc_list</string>
<string>reference_search_list</string>
<string>text_search_list</string>
<string>_getiter_</string>
<string>text</string>
<string>prop_dict</string>
<string>_getitem_</string>
<string>follow_up_type_list</string>
<string>follow_up</string>
<string>None</string>
<string>result</string>
<string>_write_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Event_getPropertyDictFromContent</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple>
<string>Prints, but never reads \'printed\' variable.</string>
</tuple>
</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