~ubuntu-branches/ubuntu/precise/landscape-client/precise

« back to all changes in this revision

Viewing changes to landscape/broker/client.py

  • Committer: Package Import Robot
  • Author(s): Andreas Hasenack
  • Date: 2012-03-19 09:33:34 UTC
  • mto: This revision was merged to the branch mainline in revision 41.
  • Revision ID: package-import@ubuntu.com-20120319093334-oxjttz163vvfgq8s
Tags: upstream-12.04
ImportĀ upstreamĀ versionĀ 12.04

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
        """An alias for the C{client} attribute."""
42
42
        return self.client
43
43
 
 
44
    def call_on_accepted(self, type, callable, *args, **kwargs):
 
45
        """
 
46
        Register a callback fired upon a C{message-type-acceptance-changed}.
 
47
        """
 
48
 
 
49
        def acceptance_changed(acceptance):
 
50
            if acceptance:
 
51
                return callable(*args, **kwargs)
 
52
 
 
53
        self.client.reactor.call_on(("message-type-acceptance-changed", type),
 
54
                                    acceptance_changed)
 
55
 
44
56
 
45
57
class BrokerClient(object):
46
58
    """Basic plugin registry for clients that have to deal with the broker.
53
65
        defined by sub-classes.
54
66
    @ivar broker: A reference to a connected L{RemoteBroker}, it must be set
55
67
        by the connecting machinery at service startup.
 
68
 
 
69
    @param reactor: A L{TwistedReactor}.
56
70
    """
57
71
    name = "client"
58
72
 
59
73
    def __init__(self, reactor):
60
 
        """
61
 
        @param reactor: A L{TwistedReactor}.
62
 
        """
63
74
        super(BrokerClient, self).__init__()
64
75
        self.reactor = reactor
65
76
        self.broker = None