Commit ddb07623 authored by Ivan Tyagov's avatar Ivan Tyagov

Use ERP5Type.ConnectionPlugin.TimeoutTransport plugin.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37232 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d8df850e
......@@ -30,8 +30,6 @@
import xmlrpclib, base64, re, zipfile, cStringIO
from warnings import warn
from xmlrpclib import Fault
from xmlrpclib import Transport
from xmlrpclib import SafeTransport
from AccessControl import ClassSecurityInfo
from AccessControl import Unauthorized
from OFS.Image import Pdata
......@@ -57,41 +55,15 @@ from Products.ERP5.mixin.base_convertable import BaseConvertableFileMixin
from Products.ERP5.mixin.text_convertable import TextConvertableMixin
from Products.ERP5.mixin.extensible_traversable import OOoDocumentExtensibleTraversableMixin
# connection plugins
from Products.ERP5Type.ConnectionPlugin.TimeoutTransport import TimeoutTransport
enc=base64.encodestring
dec=base64.decodestring
_MARKER = []
EMBEDDED_FORMAT = '_embedded'
class TimeoutTransport(SafeTransport):
"""A xmlrpc transport with configurable timeout.
"""
def __init__(self, timeout=None, scheme='http'):
self._timeout = timeout
self._scheme = scheme
# On Python 2.6, .__init__() of Transport and SafeTransport must be called
# to set up the ._use_datetime attribute.
# sigh... too bad we can't use super() here, as SafeTransport is not
# a new-style class (as of Python 2.4 to 2.6)
# remove the gettattr below when we drop support for Python 2.4
super__init__ = getattr(SafeTransport, '__init__', lambda self: None)
super__init__(self)
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(OOoDocumentExtensibleTraversableMixin, BaseConvertableFileMixin, File,
TextConvertableMixin, Document):
"""
......
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