Commit 506207fa authored by Yusei Tahara's avatar Yusei Tahara

Removed unused old scripts.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18254 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 698bc8d5
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</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
The email ingestion script, called by ZMailIn upon reception of an email.\n
Finds out who sent the letter, finds the sender, discovers properties that may\n
be contained in the mail body (using Document_getPropertyListFromMail),\n
then creates and object from every attachment and sends notifications to the \n
sender.\n
\n
If it returns anything, it is bounced back to the sender as an error message. No return\n
value means everything was fine.\n
"""\n
# get sender from email headers\n
raw_sender_email = theMail[\'headers\'][\'from\']\n
sender_email = context.findAddress(raw_sender_email)\n
if sender_email is None:\n
msg = \'[DMS] No sender in email message\'\n
context.log(msg)\n
return msg\n
\n
# find sender in ERP5\n
found_email_list = context.portal_catalog(portal_type=\'Email\', url_string=sender_email)\n
if len(found_email_list) == 0:\n
msg = \'[DMS] You are not in user database\'\n
context.log(msg)\n
return msg\n
if len(found_email_list) > 1:\n
msg = \'[DMS] Your email address has multiple entries\'\n
context.log(msg)\n
return msg\n
\n
person = found_email_list[0].getParentValue()\n
\n
# get mail properties out of mail body\n
mailprops = context.Document_getPropertyDictFromMail(theMail[\'body\'])\n
\n
# try to ingest document for each attachment\n
try:\n
for attachment in theMail[\'attachment_list\']:\n
file_name, content_type, data = attachment\n
kw = dict(file_name = file_name,\n
data = data,\n
discover_metadata = 0)\n
new_content = context.portal_contributions.newContent(**kw)\n
merged_content = new_content.discoverMetadata(file_name = file_name)\n
if new_content == merged_content:\n
# we have a new document in the system, so set local role owner to email sender\n
new_content.manage_setLocalRoles(person.getReference(), [\'Owner\',])\n
\n
new_content.immediateReindexObject()\n
merged_content.immediateReindexObject()\n
# notify sender for successful email ingestion\n
context.Document_notifyByEmail(sender_email, \'ingestion_success\', merged_content)\n
context.log(\'[DMS] Finished email ingestion for %s <%s> (%s)\' \n
%(person.getTitle(), sender_email, file_name))\n
return 0\n
except Exception, e:\n
# failure during ingestion, inform user to try again later\n
context.Document_notifyByEmail(sender_email, \n
\'ingestion_failure\', \n
context, \n
original_email = theMail)\n
context.log(\'[DMS] Failure (%s) email ingestion for %s <%s>\' \n
%(e, person.getTitle(), sender_email))\n
raise Exception, e\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>_params</string> </key>
<value> <string>theMail</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</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>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>theMail</string>
<string>_getitem_</string>
<string>raw_sender_email</string>
<string>_getattr_</string>
<string>context</string>
<string>sender_email</string>
<string>None</string>
<string>msg</string>
<string>found_email_list</string>
<string>len</string>
<string>person</string>
<string>mailprops</string>
<string>_getiter_</string>
<string>attachment</string>
<string>file_name</string>
<string>content_type</string>
<string>data</string>
<string>dict</string>
<string>kw</string>
<string>_apply_</string>
<string>new_content</string>
<string>merged_content</string>
<string>Exception</string>
<string>e</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>Document_ingestEmail</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Ingest document from an email message</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</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
Used by email ingestor (Document_ingestEmail) to notify the user\n
about ingestion of a document (can also be used by other ingestion channels).\n
Checks consistency and lets the user know if everything is ok (this is a bit of a duplication\n
because consistency is checked also upon an attempt to validate).\n
\n
Preferences decide if the notification is sent always, only if something is wrong or never.\n
\n
Notifcation contains url of the document, so that one can click and do something.\n
"""\n
\n
# check if we send or not email at all\n
original_email = kw.get(\'original_email\', None)\n
portal = context.getPortalObject()\n
portal_preferences = portal.portal_preferences\n
portal_catalog = portal.portal_catalog\n
pref = portal_preferences.getPreferredDocumentIngestionEmailNotification()\n
if pref is not None and len(pref) != 0:\n
pref=pref[0]\n
if pref == \'never\':\n
# do not send any email notifications at all \n
return\n
\n
if event in (\'ingestion_success\',):\n
# successful ingestion socheck if ingested document is consistent\n
if doc.getPortalType() == \'Memo\': \n
# we don\'t check constistency for Memo XXX use type groups, or what?\n
isObjectConsistent = True\n
else:\n
consistency_result = doc.checkConsistency()\n
consistency_result = [x for x in consistency_result if x[1] == \'DocumentCoordinatesConstraint inconsistency\']\n
isObjectConsistent = len(consistency_result) == 0\n
if not isObjectConsistent:\n
error_msg = \'<br/>\'.join(str(x[3]) for x in consistency_result)\n
subject_template = \'[DMS] Failure ingestion %(name)s\'\n
email_template = """Your document "%(name)s" was not successfuly ingested.\n
\n
The following problems were detected:\n
\n
%(error_msg)s\n
\n
click here: %(url)s/view to proceed and fix the problems.\n
"""\n
else:\n
error_msg = \'\'\n
subject_template = \'[DMS] Successful ingestion for %(name)s\'\n
email_template = """Your document "%(name)s" was successfully ingested.\n
\n
click here: %(url)s/view to proceed with your work."""\n
elif event in (\'ingestion_failure\',):\n
# there was an error during ingestion process, inform user to try again\n
error_msg = kw.get(\'message\', \'Failure during ingestion.\') \n
subject_template = \'[DMS] Unsuccessful ingestion\'\n
email_template = """Your document was not successfuly ingested.\n
\n
The following problems were detected:\n
\n
%(error_msg)s\n
\n
Please try again after some time. \n
We applogize for inconvinience."""\n
\n
\n
# compose email\n
email_from = portal_preferences.getPreferredDocumentEmailIngestionAddress()\n
email_kw = dict(error_msg = error_msg)\n
\n
# not always we have ingested document passed (i.e when failure happens)\n
if getattr(doc, \'getSourceReference\', None) is not None:\n
subject = subject_template % {\'name\': doc.getSourceReference()}\n
email_kw[\'name\'] = doc.getSourceReference()\n
email_kw[\'url\'] = doc.absolute_url()\n
else:\n
subject = subject_template\n
\n
# get original email text\n
original_email_text = None\n
if original_email is not None:\n
original_email_text = \'Subject:%s\\n\\nBody:\\n%s\' %(original_email[\'headers\'][\'subject\'], \n
original_email[\'body\'])\n
email_text = email_template % email_kw\n
# add part of original email if failure happens\n
if event in (\'ingestion_failure\',) and original_email_text is not None:\n
email_text = \'%s\\n\\n%s\\nOriginal email text (see below):\\n\\n%s\' %(email_text, \n
\'=\'*80, \n
original_email_text)\n
# send email\n
context.MailHost.send(email_text, \n
email_to, \n
email_from, \n
subject)\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>_params</string> </key>
<value> <string>email_to, event, doc, **kw</string> </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>3</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>email_to</string>
<string>event</string>
<string>doc</string>
<string>kw</string>
<string>_getattr_</string>
<string>None</string>
<string>original_email</string>
<string>context</string>
<string>portal</string>
<string>portal_preferences</string>
<string>portal_catalog</string>
<string>pref</string>
<string>len</string>
<string>_getitem_</string>
<string>True</string>
<string>isObjectConsistent</string>
<string>consistency_result</string>
<string>append</string>
<string>$append0</string>
<string>_getiter_</string>
<string>x</string>
<string>error_msg</string>
<string>subject_template</string>
<string>email_template</string>
<string>email_from</string>
<string>dict</string>
<string>email_kw</string>
<string>getattr</string>
<string>subject</string>
<string>_write_</string>
<string>original_email_text</string>
<string>email_text</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>Document_notifyByEmail</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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 function sends a notification mail to person who is allowed to modify\n
current document.\n
"""\n
\n
persons_to_inform = []\n
\n
# find which persons have needed roles so they can be informed\n
person_list = context.getPortalObject().portal_catalog(portal_type = \'Person\', reference=\'%\')\n
for person in person_list:\n
local_roles = context.Document_getPersonRoleList(person, context)\n
# check if person\'s roles in this document\'s context allow him/her to modify it\n
intersect = [k for k in local_roles if k in roles_to_inform]\n
if len(intersect) > 0:\n
persons_to_inform.append(person)\n
\n
# email templates\n
if event in (\'release\',):\n
subject_template = \'[DMS] Document owned by you was released.\'\n
email_template = """Your document "%(name)s" was released.\n
\n
click here: %(url)s/view to check it."""\n
elif event in (\'publish\',):\n
subject_template = \'[DMS] Document owned by you was published.\'\n
email_template = """Your document "%(name)s" was published.\n
\n
click here: %(url)s/view to check it."""\n
\n
# send email to owner\n
for person in persons_to_inform:\n
email_subject = subject_template %dict(name = context.getTitle())\n
email_text = email_template % dict(name = context.getTitle(),\n
url = context.absolute_url())\n
email_to = person.getDefaultEmailText()\n
context.MailHost.send(messageText = email_text, \n
mto = email_to, \n
mfrom = \'dms@dms.nexedi.com\', \n
subject = email_subject)\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>_params</string> </key>
<value> <string>event=\'publish\', roles_to_inform = (\'Owner\', \'Assignor\',)</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</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>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>event</string>
<string>roles_to_inform</string>
<string>persons_to_inform</string>
<string>_getattr_</string>
<string>context</string>
<string>person_list</string>
<string>_getiter_</string>
<string>person</string>
<string>local_roles</string>
<string>append</string>
<string>$append0</string>
<string>k</string>
<string>intersect</string>
<string>len</string>
<string>subject_template</string>
<string>email_template</string>
<string>dict</string>
<string>email_subject</string>
<string>email_text</string>
<string>email_to</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<string>publish</string>
<tuple>
<string>Owner</string>
<string>Assignor</string>
</tuple>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Document_notifyOnChange</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
758
\ No newline at end of file
759
\ No newline at end of file
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