Commit 3d64618a authored by Yusei Tahara's avatar Yusei Tahara

Fixed a wrong argument.

Get keyword arguments from state change info instead of request.
Clean up code.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18309 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 049abb1d
...@@ -3,11 +3,8 @@ ...@@ -3,11 +3,8 @@
<record id="1" aka="AAAAAAAAAAE="> <record id="1" aka="AAAAAAAAAAE=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<string>Products.PythonScripts.PythonScript</string> <tuple/>
<string>PythonScript</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
...@@ -68,29 +65,35 @@ ...@@ -68,29 +65,35 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string encoding="cdata"><![CDATA[
"""\n
when OOoDocument is edited, we update metadata in the ODF file\n when OOoDocument is edited, we update metadata in the ODF file\n
\n \n
XXX - This script must be verified, written with clean syntax \n XXX - This script must be verified, written with clean syntax \n
and using less horrible methods (request lookup yuk!)\n and using less horrible methods (request lookup yuk!)\n
"""\n """\n
\n document = state_change[\'object\']\n
ob=state_change[\'object\']\n kw = state_change[\'kwargs\']\n
kw=ob.REQUEST\n metadata_field_list = (\'title\', \'subject\', \'description\', \'reference\', \'version\', \'language\') # XXX hardcoded?\n
metafields=(\'title\',\'subject\',\'description\',\'reference\',\'version\',\'language\') # XXX hardcoded?\n
f=kw.get(\'my_file\',None)\n
\n \n
# edit metadata (only if we have OOo file)\n # edit metadata (only if we have OOo file)\n
if ob.hasBaseData():\n if document.hasBaseData():\n
newmeta={}\n new_metadata = {}\n
for mf in metafields:\n for field in metadata_field_list:\n
keymf=\'my_\'+mf\n value = kw.get(field, None)\n
if kw.has_key(keymf):\n if value is None:\n
newmeta[mf]=kw[keymf]\n value_list = kw.get(\'%s_list\' % field, None)\n
if newmeta:\n if value_list is not None and len(value_list)>0:\n
value = \' \'.join(map(str, value_list))\n
if value is not None:\n
new_metadata[field] = value \n
if new_metadata:\n
# edit metadata via server\n # edit metadata via server\n
ob.activate().updateBaseMetadata(newmeta)\n document.activate().updateBaseMetadata(**new_metadata)\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -140,17 +143,21 @@ if ob.hasBaseData():\n ...@@ -140,17 +143,21 @@ if ob.hasBaseData():\n
<tuple> <tuple>
<string>state_change</string> <string>state_change</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>ob</string> <string>document</string>
<string>_getattr_</string>
<string>kw</string> <string>kw</string>
<string>metafields</string> <string>metadata_field_list</string>
<string>None</string> <string>_getattr_</string>
<string>f</string> <string>new_metadata</string>
<string>newmeta</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>mf</string> <string>field</string>
<string>keymf</string> <string>None</string>
<string>value</string>
<string>value_list</string>
<string>len</string>
<string>map</string>
<string>str</string>
<string>_write_</string> <string>_write_</string>
<string>_apply_</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
764 766
\ No newline at end of file \ 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