Commit cbcc6be8 authored by Bartek Górny's avatar Bartek Górny

utilities to convert and generate files outside OOoDocument objects (from raw data)

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11237 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent adb557d2
import zipfile, cStringIO, re import zipfile, cStringIO, re
import xmlrpclib, base64
from Products.CMFCore.utils import getToolByName
rx_atr='([\w]+)###([\w/]+)' rx_atr='([\w]+)###([\w/]+)'
rx_atr=re.compile(rx_atr) rx_atr=re.compile(rx_atr)
...@@ -23,4 +25,27 @@ def getDoctypeFromContent(data): ...@@ -23,4 +25,27 @@ def getDoctypeFromContent(data):
atrs=getAttrFromContent(data) atrs=getAttrFromContent(data)
return atrs.get('doctype') 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 # vim: syntax=python shiftwidth=2
326 327
\ 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