Commit 2f09e46c authored by Bartek Górny's avatar Bartek Górny

Reading doc properties from content and from email text upon ingestion

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11214 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e2733759
......@@ -6,5 +6,14 @@ def findAddress(txt):
m=r.search(txt)
return m and m.group()
def extractParams(txt):
r=re.compile('^([\w_]+):([\w_/]+)$')
res=[]
for line in txt.split():
found=r.findall(line.strip())
if len(found)==1:
res.append(found[0])
return dict(res)
# vim: shiftwidth=2
......@@ -96,10 +96,18 @@ senderm=r[0]\n
person=senderm.getParent()\n
context.log(script.getId(),\'ok, this address belongs to \'+person.getRelativeUrl())\n
\n
mailprops=context.Document_getPropertiesFromMail(theMail[\'body\'])\n
context.log(mailprops)\n
# create objects from attachments\n
try:\n
for fname,data in theMail[\'attachments\'].items():\n
obj=context.DMS_createObjectFromFile(fname,data)\n
obj=context.DMS_createObjectFromFile(fname,data,mailprops.get(\'document_type\'))\n
# if some properties were in the mail, overwrite the content attrs\n
for k in mailprops:\n
atr=k\n
if k==\'programme\':atr=\'source_project\'\n
if k!=\'document_type\':\n
obj.setProperty(atr,mailprops[k])\n
obj.setGroup(person.getSubordinationValue().getGroup())\n
obj.manage_setLocalRoles(person.getReference(),[\'Owner\',])\n
context.DMS_notifyByEmail(address=senderemail,event=\'ingest\',object=obj)\n
......@@ -173,10 +181,13 @@ return\n
<string>senderm</string>
<string>person</string>
<string>script</string>
<string>mailprops</string>
<string>_getiter_</string>
<string>fname</string>
<string>data</string>
<string>obj</string>
<string>k</string>
<string>atr</string>
<string>Exception</string>
<string>e</string>
<string>str</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.ExternalMethod.ExternalMethod</string>
<string>ExternalMethod</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_function</string> </key>
<value> <string>extractParams</string> </value>
</item>
<item>
<key> <string>_module</string> </key>
<value> <string>mailUtils</string> </value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Document_getPropertiesFromMail</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
2006-11-08
Reading doc properties from content and from email text upon ingestion
2006-11-02
Deletion in publication workflow
Advanced search dialog for putting together search string (Google-like)
......
321
\ No newline at end of file
324
\ 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