Commit aa9ffd30 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Quick hack to support new protocol. More error handling and retry needed....

Quick hack to support new protocol. More error handling and retry needed. Every protocol error must raise an exception.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14382 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3a545fc8
...@@ -184,12 +184,18 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -184,12 +184,18 @@ class OOoDocument(File, ConversionCacheMixin):
def cached_getTargetFormatItemList(content_type): def cached_getTargetFormatItemList(content_type):
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
try: try:
allowed = server_proxy.getAllowedTargetItemList(content_type) response_code, response_dict, response_message = server_proxy.getAllowedTargetItemList(content_type)
if response_code == 200:
allowed = response_dict['response_data']
else:
# This is very temporary code - XXX needs to be changed
# so that the system can retry
raise ConversionError(response_code), response_message
except Fault, f: except Fault, f:
allowed = server_proxy.getAllowedTargets(content_type) allowed = server_proxy.getAllowedTargets(content_type)
warn('Your oood version is too old, using old method ' warn('Your oood version is too old, using old method '
'getAllowedTargets instead of getAllowedTargetList', 'getAllowedTargets instead of getAllowedTargetList',
DeprecationWarning) DeprecationWarning)
# tuple order is reversed to be compatible with ERP5 Form # tuple order is reversed to be compatible with ERP5 Form
return [(y, x) for x, y in allowed] return [(y, x) for x, y in allowed]
...@@ -243,16 +249,15 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -243,16 +249,15 @@ class OOoDocument(File, ConversionCacheMixin):
z.close() z.close()
return 'text/plain', s return 'text/plain', s
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
try: response_code, response_dict, response_message = server_proxy.run_generate(self.getId(),
kw = server_proxy.run_generate(self.getId(),
enc(_unpackData(self.getBaseData())), enc(_unpackData(self.getBaseData())),
None, None,
format) format)
except Exception, inst: #except Exception, inst:
# Catch, log and raise errors with converting server.Explicitly raise the exception! # # Catch, log and raise errors with converting server.Explicitly raise the exception!
LOG('[DMS]', ERROR, 'Error generating document %s' %inst) # LOG('[DMS]', ERROR, 'Error generating document %s' % inst)
raise Exception # raise Exception
return kw['mime'], Pdata(dec(kw['data'])) return response_dict['mime'], Pdata(dec(response_dict['data']))
# Conversion API # Conversion API
security.declareProtected(Permissions.View, 'convert') security.declareProtected(Permissions.View, 'convert')
......
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