Commit f70e8e24 authored by Jérome Perrin's avatar Jérome Perrin

Increase timeout when talking to oood



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14986 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2fe377d0
......@@ -29,6 +29,8 @@ import xmlrpclib, base64, re, zipfile, cStringIO, socket
from warnings import warn
from DateTime import DateTime
from xmlrpclib import Fault
from xmlrpclib import Transport
from xmlrpclib import SafeTransport
from AccessControl import ClassSecurityInfo
from OFS.Image import Pdata
from Products.CMFCore.utils import getToolByName, _setCacheHeaders
......@@ -48,6 +50,29 @@ dec=base64.decodestring
_MARKER = []
STANDARD_IMAGE_FORMAT_LIST = ('png', 'jpg', 'gif', )
class TimeoutTransport(SafeTransport):
"""A xmlrpc transport with configurable timeout.
"""
def __init__(self, timeout=None, scheme='http'):
self._timeout = timeout
self._scheme = scheme
def send_content(self, connection, request_body):
connection.putheader("Content-Type", "text/xml")
connection.putheader("Content-Length", str(len(request_body)))
connection.endheaders()
if self._timeout:
connection._conn.sock.settimeout(self._timeout)
if request_body:
connection.send(request_body)
def make_connection(self, h):
if self._scheme == 'http':
return Transport.make_connection(self, h)
return SafeTransport.make_connection(self, h)
class OOoDocument(File, ConversionCacheMixin):
"""
A file document able to convert OOo compatible files to
......@@ -165,8 +190,10 @@ class OOoDocument(File, ConversionCacheMixin):
"""
Create an XML-RPC proxy to access the conversion server.
"""
server_proxy = xmlrpclib.ServerProxy('http://%s:%d' % self._getServerCoordinate(),
allow_none=True)
server_proxy = xmlrpclib.ServerProxy(
'http://%s:%d' % self._getServerCoordinate(),
allow_none=True,
transport=TimeoutTransport(timeout=360, scheme='http'))
return server_proxy
security.declareProtected(Permissions.AccessContentsInformation,
......
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