Exemplo n.º 1
0
    def _evaluate1(self, response):
        remoteInterfaceName, methodName = self.readString(), self.readString()

        try:
            remoteInterface = remoteInterfaceRegistry[remoteInterfaceName]
        except KeyError:
            raise

        provider = remoteInterface(self.servlet, None)
        if provider is None:
            raise error.NoSuchInterface()

        try:
            methodSignature = remoteInterface[methodName]
        except KeyError:
            raise error.NoSuchMethod()

        # The argument type signatures are embedded in the token stream,
        # so the server can figure out what method to invoke if there are
        # several methods with the same name.
        #
        # We do not really case since we can only have one method per name.
        # But we read them the signatures and build annotations, to
        #
        #  (1) know how to deserialize the values, and
        #  (2) check signatures
        count = self.readInt()
        argTypeNames = [self.readString() for i in range(count)]
        argTypeInstances = [annotation.buildAnnotation(t) for t in argTypeNames]
        arguments = self.deserializeValues(argTypeInstances)

        # invoke method:
        return self.invoke(
            provider, methodSignature, arguments, response
            )
Exemplo n.º 2
0
 def deserializeObject(self, typeSignature):
     """Deserialize an object according to the given type signature.
     """
     id = self.reserveObject()
     typeInstance = annotation.buildAnnotation(typeSignature)
     customSerializer = annotation.getCustomFieldSerializer(typeInstance)
     instance = customSerializer.deserialize(self)
     self.rememberObject(instance, id)
     return instance