Python Pyro4.expose() Examples

The following are 2 code examples of Pyro4.expose(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module Pyro4 , or try the search function .
Example #1
Source File: expose_method.py    From MCVirt with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, locking=False, object_type=None,
                 instance_method=None, remote_nodes=False,
                 support_callback=False,
                 undo_method=None,
                 expose=True,  # Determine whether the method is actually
                               # exposed to pyro
                 remote_method=None,
                 remote_undo_method=None):
        """Setup variables passed in via decorator as member variables."""
        self.locking = locking
        self.object_type = object_type
        self.instance_method = instance_method
        self.remote_nodes = remote_nodes
        self.support_callback = support_callback
        self.undo_method = undo_method
        self.expose = expose
        self.remote_method = remote_method
        self.remote_undo_method = remote_undo_method 
Example #2
Source File: expose_method.py    From MCVirt with GNU General Public License v2.0 5 votes vote down vote up
def __call__(self, callback):
        """Run when object is created.

        The returned value is the method that is executed
        """
        def inner(self_obj, *args, **kwargs):
            """Run when the wrapping method is called."""
            # Create function object and run
            function = Function(function=callback, obj=self_obj,
                                args=args, kwargs=kwargs,
                                locking=self.locking,
                                object_type=self.object_type,
                                instance_method=self.instance_method,
                                remote_nodes=self.remote_nodes,
                                support_callback=self.support_callback,
                                undo_method=self.undo_method,
                                remote_method=self.remote_method,
                                remote_undo_method=self.remote_undo_method)
            return_val = function.run()
            function.unregister()
            return return_val

        # Expose the function
        if self.expose:
            return Pyro4.expose(inner)
        else:
            return inner