Ticket #3219: xmlrpc_datetime_r28820.diff

File xmlrpc_datetime_r28820.diff, 3.0 KB (added by chadmaine, 7 years ago)

Updated against r28820

  • twisted/web/xmlrpc.py

     
    9292    separator = '.'
    9393    allowedMethods = ('POST',)
    9494
    95     def __init__(self, allowNone=False):
     95    def __init__(self, allowNone=False, useDateTime=False):
    9696        resource.Resource.__init__(self)
    9797        self.subHandlers = {}
    9898        self.allowNone = allowNone
     99        self.useDateTime = useDateTime
    99100
    100101    def putSubHandler(self, prefix, handler):
    101102        self.subHandlers[prefix] = handler
     
    110111        request.content.seek(0, 0)
    111112        request.setHeader("content-type", "text/xml")
    112113        try:
    113             args, functionPath = xmlrpclib.loads(request.content.read())
     114            args, functionPath = xmlrpclib.loads(request.content.read(),
     115                use_datetime=self.useDateTime)
    114116        except Exception, e:
    115117            f = Fault(self.FAILURE, "Can't deserialize input: %s" % (e,))
    116118            self._cbRender(f, request)
     
    303305    protocol = QueryProtocol
    304306
    305307    def __init__(self, path, host, method, user=None, password=None,
    306                  allowNone=False, args=(), canceller=None):
     308                 allowNone=False, args=(), canceller=None, useDateTime=False):
    307309        """
    308310        @type path: C{str}
    309311        @param path: The path portion of the URL to which to post method calls.
     
    338340        self.payload = payloadTemplate % (method,
    339341            xmlrpclib.dumps(args, allow_none=allowNone))
    340342        self.deferred = defer.Deferred(canceller)
     343        self.useDateTime = useDateTime
    341344
    342345    def parseResponse(self, contents):
    343346        if not self.deferred:
    344347            return
    345348        try:
    346             response = xmlrpclib.loads(contents)[0][0]
     349            response = xmlrpclib.loads(contents,
     350                use_datetime=self.useDateTime)[0][0]
    347351        except:
    348352            deferred, self.deferred = self.deferred, None
    349353            deferred.errback(failure.Failure())
     
    378382    """
    379383    queryFactory = _QueryFactory
    380384
    381     def __init__(self, url, user=None, password=None, allowNone=False):
     385    def __init__(self, url, user=None, password=None, allowNone=False,
     386                 useDateTime=False):
    382387        """
    383388        @type url: C{str}
    384389        @param url: The URL to which to post method calls.  Calls will be made
     
    428433        if password is not None:
    429434            self.password = password
    430435        self.allowNone = allowNone
     436        self.useDateTime = useDateTime
    431437
    432438    def callRemote(self, method, *args):
    433439        """
     
    447453            connector.disconnect()
    448454        factory = self.queryFactory(
    449455            self.path, self.host, method, self.user,
    450             self.password, self.allowNone, args, cancel)
     456            self.password, self.allowNone, args, cancel, self.useDateTime)
    451457        if self.secure:
    452458            from twisted.internet import ssl
    453459            connector = reactor.connectSSL(self.host, self.port or 443,