Exemplo n.º 1
0
 def mapPyforaInstanceToPythonInstance(self, instance):
     """Given an instance of the pure-python class, return an instance of the mappable type."""
     # subclasses should implement
     raise Exceptions.PyforaNotImplementedError(
         "'%s' not implemented yet for type '%s'" %
         (self.mapPyforaInstanceToPythonInstance.__name__,
          type(self).__name__))
Exemplo n.º 2
0
 def mapPythonInstanceToPyforaInstance(self, instance):
     assert instance is self.instance
     if self.pureClass is None:
         raise Exceptions.PyforaNotImplementedError(
             "conversion of '%s' not yet implemented" %
             (instance.__name__
              if hasattr(instance, "__name__") else instance))
     return self.pureClass()
Exemplo n.º 3
0
    def getPurePythonTypes(self):
        """Return the pure-python type that this mapping converts to.

        This should return a list of python classes that this mapper knows how to invert.
        """
        #subclasses should implement
        raise Exceptions.PyforaNotImplementedError(
            "'%s' not implemented yet for type '%s'" %
            (self.getPurePythonTypes.__name__, type(self).__name__))
Exemplo n.º 4
0
    def toLocal(self):
        """Downloads the remote object.

        Returns:
            A :class:`~pyfora.Future.Future` that resolves to the python
            object that this :class:`RemotePythonObject` represents.
        """
        raise Exceptions.PyforaNotImplementedError(
            "'%s' not implemented yet for type '%s'" %
            (self.toLocal.__name__, type(self).__name__))
Exemplo n.º 5
0
    def getMappablePythonTypes(self):
        """Return the python type that this mapping knows how to convert.

        This should return a list of python types and classes. Any time the
        converter sees an instance of one of these types, Pyfora will invoke
        this class to provide an alternate, translatable form of the instance.
        """
        #subclasses should implement
        raise Exceptions.PyforaNotImplementedError(
            "'%s' not implemented yet for type '%s'" %
            (self.getMappablePythonTypes.__name__, type(self).__name__))
Exemplo n.º 6
0
    def submit(self, fn, *args, **kwargs):
        """Submits a callable to be executed on the server with the provided arguments 'args'.
        kwargs are not currently supported.

        Returns:
            A Future representing the given call. The future will eventually resolve to a
            RemotePythonObject instance.
        """
        self._raiseIfClosed()
        if len(kwargs) > 0:
            raise Exceptions.PyforaNotImplementedError(
                "Keyword arguments not supported yet")

        # TODO: make this truly async
        #       don't block on the 'define' calls
        futures = [self.define(fn)] + [self.define(arg) for arg in args]
        results = [f.result() for f in futures]
        return results[0](*results[1:])
Exemplo n.º 7
0
 def getMappableInstances(self):
     """Return a list of specific instances this mapper knows how to convert."""
     #subclasses should implement
     raise Exceptions.PyforaNotImplementedError(
         "'%s' not implemented yet for type '%s'" %
         (self.getMappableInstances.__name__, type(self).__name__))
Exemplo n.º 8
0
 def toLocal(self):
     """Produce a Future that resolves to the actual python object
     that this RemotePythonObject represents."""
     raise Exceptions.PyforaNotImplementedError(
         "'%s' not implemented yet for type '%s'" %
         (self.toLocal.__name__, type(self).__name__))