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 ...@@ -32,6 +32,7 @@ import re
import zipfile import zipfile
import cStringIO import cStringIO
import socket import socket
from warnings import warn
from DateTime import DateTime from DateTime import DateTime
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
...@@ -176,7 +177,8 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -176,7 +177,8 @@ class OOoDocument(File, ConversionCacheMixin):
allow_none=True) allow_none=True)
return server_proxy return server_proxy
security.declareProtected(Permissions.AccessContentsInformation,'getTargetFormatList') security.declareProtected(Permissions.AccessContentsInformation,
'getTargetFormatItemList')
def getTargetFormatItemList(self): def getTargetFormatItemList(self):
""" """
Returns a list of acceptable formats for conversion Returns a list of acceptable formats for conversion
...@@ -187,13 +189,22 @@ class OOoDocument(File, ConversionCacheMixin): ...@@ -187,13 +189,22 @@ class OOoDocument(File, ConversionCacheMixin):
""" """
def cached_getTargetFormatItemList(content_type): def cached_getTargetFormatItemList(content_type):
server_proxy = self._mkProxy() server_proxy = self._mkProxy()
allowed = server_proxy.getAllowedTargetItemList(content_type) # oood API needs naming convention update try:
return [(y, x) for x, y in allowed] # tuple order is reversed to be compatible with ERP5 Form 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 # Cache valid format list
cached_getTargetFormatItemList = CachingMethod(cached_getTargetFormatItemList, cached_getTargetFormatItemList = CachingMethod(
id = "OOoDocument_getTargetFormatItemList", cached_getTargetFormatItemList,
cache_factory='erp5_ui_medium') id="OOoDocument_getTargetFormatItemList",
cache_factory='erp5_ui_medium')
return cached_getTargetFormatItemList(self.getBaseContentType()) 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