Ejemplo n.º 1
0
 def test_referenceable(self):
     h = common.HelperTarget()
     c1 = RemoteInterfaceConstraint(common.RIHelper)
     c2 = RemoteInterfaceConstraint(common.RIMyTarget)
     self.violates_inbound("bogus", c1)
     self.violates_outbound("bogus", c1)
     self.check_outbound(h, c1)
     self.violates_inbound(h, c1)
     self.violates_inbound(h, c2)
     self.violates_outbound(h, c2)
Ejemplo n.º 2
0
    def test_remotereference(self):
        # we need to create a fake RemoteReference here
        tracker = RemoteReferenceTracker(broker.Broker(TubRef("fake-tubid")),
                                         0, None,
                                         common.RIHelper.__remote_name__)
        rr = RemoteReference(tracker)

        c1 = RemoteInterfaceConstraint(common.RIHelper)
        self.check_inbound(rr, c1)
        self.check_outbound(rr, c1)  # gift

        c2 = RemoteInterfaceConstraint(common.RIMyTarget)
        self.violates_inbound(rr, c2)
        self.violates_outbound(rr, c2)
Ejemplo n.º 3
0
            if self._interface:
                self._interfaceName = self._interface.__remote_name__
            else:
                self._interfaceName = None
        return self._interface

    def getInterfaceName(self):
        self.getInterface()
        return self._interfaceName

    def doRemoteCall(self, methodname, args, kwargs):
        meth = getattr(self, "remote_%s" % methodname)
        res = meth(*args, **kwargs)
        return res

constraintMap[Referenceable] = RemoteInterfaceConstraint(None)


class ReferenceableTracker:
    """I hold the data which tracks a local Referenceable that is in used by
    a remote Broker.

    @ivar obj: the actual object
    @ivar refcount: the number of times this reference has been sent to the
                    remote end, minus the number of DECREF messages which it
                    has sent back. When it goes to zero, the remote end has
                    forgotten the RemoteReference, and is prepared to forget
                    the RemoteReferenceData as soon as the DECREF message is
                    acknowledged.
    @ivar clid: the connection-local ID used to represent this object on the
                wire.