diff --git a/bt5/erp5_dms/ExtensionTemplateItem/documentUtils.py b/bt5/erp5_dms/ExtensionTemplateItem/documentUtils.py index f10a56c344037be0869bb249169b58c19eb85f5b..e37af5a65b343487c0ef1eb26bcc8b046d617862 100644 --- a/bt5/erp5_dms/ExtensionTemplateItem/documentUtils.py +++ b/bt5/erp5_dms/ExtensionTemplateItem/documentUtils.py @@ -1,4 +1,6 @@ import zipfile, cStringIO, re +import xmlrpclib, base64 +from Products.CMFCore.utils import getToolByName rx_atr='([\w]+)###([\w/]+)' rx_atr=re.compile(rx_atr) @@ -23,4 +25,27 @@ def getDoctypeFromContent(data): atrs=getAttrFromContent(data) return atrs.get('doctype') +def convertToOdf(name,data): + sp=mkProxy() + kw=sp.run_convert(name,data) + odf=base64.decodestring(kw['data']) + return odf + +def mkProxy(self): + pref=getToolByName(self,'portal_preferences') + adr=pref.getPreferredDmsOoodocServerAddress() + nr=pref.getPreferredDmsOoodocServerPortNumber() + if adr is None or nr is None: + raise Exception('you should set conversion server coordinates in preferences') + sp=xmlrpclib.ServerProxy('http://%s:%d' % (adr,nr),allow_none=True) + return sp + +def generateFile(self,name,data,format): + sp=mkProxy(self) + kw=sp.run_generate(name,data,None,format) + res=base64.decodestring(kw['data']) + return res + + + # vim: syntax=python shiftwidth=2 diff --git a/bt5/erp5_dms/bt/revision b/bt5/erp5_dms/bt/revision index 95738485793d46fac341b01b1f8f9468b4df0dd1..98c1572f67e72c2c54c6e949b21406e146df0b5b 100644 --- a/bt5/erp5_dms/bt/revision +++ b/bt5/erp5_dms/bt/revision @@ -1 +1 @@ -326 \ No newline at end of file +327 \ No newline at end of file