Exemple #1
0
    def _test_encode(self, valuesWithEncoders):
        values, encoders = zip(*valuesWithEncoders)
        inKwargs = dict(zip(string.ascii_lowercase, values))
        boxKwargs = ampencode.toBoxKwargs(inKwargs)
        self.assertEqual(len(inKwargs), len(boxKwargs))

        for key, encoder in zip(string.ascii_lowercase, encoders):
            self.assertEqual(boxKwargs[key], encoder.toString(inKwargs[key]))
Exemple #2
0
    def _test_encode(self, valuesWithEncoders):
        values, encoders = zip(*valuesWithEncoders)
        inKwargs = dict(zip(string.ascii_lowercase, values))
        boxKwargs = ampencode.toBoxKwargs(inKwargs)
        self.assertEqual(len(inKwargs), len(boxKwargs))

        for key, encoder in zip(string.ascii_lowercase, encoders):
            self.assertEqual(boxKwargs[key], encoder.toString(inKwargs[key]))
Exemple #3
0
def handleRequest(string, client, write):
    """
    Handles an incoming request.
    """
    identifier, requiresAnswer = None, False

    try:
        request = _parseRequest(string)
        method, identifier, kwargs = _extractDetails(request)
        boxKwargs = ampencode.toBoxKwargs(kwargs)
        requiresAnswer = identifier is not None
        d = client.callRemoteString(method, requiresAnswer, **boxKwargs)
    except Exception as e:
        d = defer.fail(e)

    if requiresAnswer:
        d.addBoth(encode, identifier)
        d.addCallback(write)
    
    return d
Exemple #4
0
def handleRequest(string, client, write):
    """
    Handles an incoming request.
    """
    identifier, requiresAnswer = None, False

    try:
        request = _parseRequest(string)
        method, identifier, kwargs = _extractDetails(request)
        boxKwargs = ampencode.toBoxKwargs(kwargs)
        requiresAnswer = identifier is not None
        d = client.callRemoteString(method, requiresAnswer, **boxKwargs)
    except Exception as e:
        d = defer.fail(e)

    if requiresAnswer:
        d.addBoth(encode, identifier)
        d.addCallback(write)

    return d