Commit 1b54e7e8 authored by Jérome Perrin's avatar Jérome Perrin

add compatibility support for old versions of oood without getAllowedTargetList

method.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14070 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 24be9db8
......@@ -32,6 +32,7 @@ import re
import zipfile
import cStringIO
import socket
from warnings import warn
from DateTime import DateTime
from AccessControl import ClassSecurityInfo
......@@ -176,7 +177,8 @@ class OOoDocument(File, ConversionCacheMixin):
allow_none=True)
return server_proxy
security.declareProtected(Permissions.AccessContentsInformation,'getTargetFormatList')
security.declareProtected(Permissions.AccessContentsInformation,
'getTargetFormatItemList')
def getTargetFormatItemList(self):
"""
Returns a list of acceptable formats for conversion
......@@ -187,13 +189,22 @@ class OOoDocument(File, ConversionCacheMixin):
"""
def cached_getTargetFormatItemList(content_type):
server_proxy = self._mkProxy()
allowed = server_proxy.getAllowedTargetItemList(content_type) # oood API needs naming convention update
return [(y, x) for x, y in allowed] # tuple order is reversed to be compatible with ERP5 Form
try:
allowed = server_proxy.getAllowedTargetItemList(content_type)
except Fault, f:
allowed = server_proxy.getAllowedTargets(content_type)
warn('Your oood version is too old, using old method '
'getAllowedTargets instead of getAllowedTargetList',
DeprecationWarning)
# tuple order is reversed to be compatible with ERP5 Form
return [(y, x) for x, y in allowed]
# Cache valid format list
cached_getTargetFormatItemList = CachingMethod(cached_getTargetFormatItemList,
id = "OOoDocument_getTargetFormatItemList",
cache_factory='erp5_ui_medium')
cached_getTargetFormatItemList = CachingMethod(
cached_getTargetFormatItemList,
id="OOoDocument_getTargetFormatItemList",
cache_factory='erp5_ui_medium')
return cached_getTargetFormatItemList(self.getBaseContentType())
......
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