Exemple #1
0
    def test_not_callable(self):
        """
        Should return C{None} if attribute exists but not callable.
        """
        self.assertTrue(hasattr(self.object, 'not_callable'))
        self.assertFalse(hasattr(self.object.not_callable, '__call__'))

        self.assertIdentical(None, util.get_callable_target(self.object,
            'not_callable'))
Exemple #2
0
    def test_callable(self):
        """
        Should return a callable if the attribute exists and is callable.
        """
        self.assertTrue(hasattr(self.object, 'callable'))
        self.assertTrue(hasattr(self.object.callable, '__call__'))

        c = util.get_callable_target(self.object, 'callable')

        self.assertNotIdentical(None, c)
        self.assertTrue(c, '__call__')
Exemple #3
0
    def findCallableByName(self, name, *args):
        """
        Used to match a callable based on the supplied name when a notify or
        invoke is encountered. Returns C{None} if not found.

        If no match is found from the superclass, the C{client}.

        All methods on a client is considered B{public} and accessible by the
        peer.
        """
        func = rtmp.ControlStream.findCallableByName(self, name, *args)

        if func:
            return func

        # all client methods are publicly accessible
        if not self.client:
            return None

        return util.get_callable_target(self.client, name)
Exemple #4
0
    def callExposedMethod(self, name, *args):
        """
        Used to match a callable based on the supplied name when a notify or
        invoke is encountered. Returns C{None} if not found.

        If no match is found from the superclass, the C{client} and then the
        C{application} are checked in that order.

        All methods on a client/application is considered B{public} and
        accessible by the peer.

        @see: L{rtmp.RTMPProtocol.getInvokableTarget}
        """
        # all client methods are publicly accessible
        client = getattr(self, 'client', None)

        if client:
            target = util.get_callable_target(client, name)

            if target:
                return defer.maybeDeferred(target, *args)

        return core.NetConnection.callExposedMethod(self, name, *args)
Exemple #5
0
    def callExposedMethod(self, name, *args):
        """
        Used to match a callable based on the supplied name when a notify or
        invoke is encountered. Returns C{None} if not found.

        If no match is found from the superclass, the C{client} and then the
        C{application} are checked in that order.

        All methods on a client/application is considered B{public} and
        accessible by the peer.

        @see: L{rtmp.RTMPProtocol.getInvokableTarget}
        """
        # all client methods are publicly accessible
        client = getattr(self, 'client', None)

        if client:
            target = util.get_callable_target(client, name)

            if target:
                return defer.maybeDeferred(target, *args)

        return core.NetConnection.callExposedMethod(self, name, *args)
Exemple #6
0
 def test_no_attr(self):
     """
     Should return C{None} if no attribute exists
     """
     self.assertFalse(hasattr(self.object, 'foo'))
     self.assertIdentical(None, util.get_callable_target(self.object, 'foo'))