コード例 #1
0
ファイル: role.py プロジェクト: bb4242/crossbar
    def from_dict(obj):
        assert(type(obj) == dict)
        if u'options' in obj:
            options = obj[u'options']
            assert(type(options) == dict)

            disclose_caller = options.get(u'disclose_caller', False)
            disclose_publisher = options.get(u'disclose_publisher', False)
            cache = options.get(u'cache', False)
        else:
            disclose_caller = False
            disclose_publisher = False
            cache = False

        uri = obj.get(u'uri', None)

        # support "starred" URIs:
        if u'match' in obj:
            # when a match policy is explicitly configured, the starred URI
            # conversion logic is skipped! we want to preserve the higher
            # expressiveness of regular WAMP URIs plus explicit match policy
            match = obj[u'match']
        else:
            # when no explicit match policy is selected, we assume the use
            # of starred URIs and convert to regular URI + detected match policy
            uri, match = convert_starred_uri(uri)

        return RouterPermissions(uri, match,
                                 call=obj.get(u'call', False),
                                 register=obj.get(u'register', False),
                                 publish=obj.get(u'publish', False),
                                 subscribe=obj.get(u'subscribe', False),
                                 disclose_caller=disclose_caller,
                                 disclose_publisher=disclose_publisher,
                                 cache=cache)
コード例 #2
0
    def from_dict(obj):
        assert (isinstance(obj, dict))

        uri = obj.get('uri', None)

        # support "starred" URIs:
        if 'match' in obj:
            # when a match policy is explicitly configured, the starred URI
            # conversion logic is skipped! we want to preserve the higher
            # expressiveness of regular WAMP URIs plus explicit match policy
            match = obj['match']
        else:
            # when no explicit match policy is selected, we assume the use
            # of starred URIs and convert to regular URI + detected match policy
            uri, match = convert_starred_uri(uri)

        allow = obj.get('allow', {})
        assert (isinstance(allow, dict))
        allow_call = allow.get('call', False)
        allow_register = allow.get('register', False)
        allow_publish = allow.get('publish', False)
        allow_subscribe = allow.get('subscribe', False)

        disclose = obj.get('disclose', {})
        assert (isinstance(disclose, dict))
        disclose_caller = disclose.get('caller', False)
        disclose_publisher = disclose.get('publisher', False)

        cache = obj.get('cache', False)

        return RouterPermissions(uri,
                                 match,
                                 call=allow_call,
                                 register=allow_register,
                                 publish=allow_publish,
                                 subscribe=allow_subscribe,
                                 disclose_caller=disclose_caller,
                                 disclose_publisher=disclose_publisher,
                                 cache=cache)
コード例 #3
0
ファイル: role.py プロジェクト: crossbario/crossbar
    def from_dict(obj):
        assert(isinstance(obj, dict))

        uri = obj.get(u'uri', None)

        # support "starred" URIs:
        if u'match' in obj:
            # when a match policy is explicitly configured, the starred URI
            # conversion logic is skipped! we want to preserve the higher
            # expressiveness of regular WAMP URIs plus explicit match policy
            match = obj[u'match']
        else:
            # when no explicit match policy is selected, we assume the use
            # of starred URIs and convert to regular URI + detected match policy
            uri, match = convert_starred_uri(uri)

        allow = obj.get(u'allow', {})
        assert(isinstance(allow, dict))
        allow_call = allow.get(u'call', False)
        allow_register = allow.get(u'register', False)
        allow_publish = allow.get(u'publish', False)
        allow_subscribe = allow.get(u'subscribe', False)

        disclose = obj.get(u'disclose', {})
        assert(isinstance(disclose, dict))
        disclose_caller = disclose.get(u'caller', False)
        disclose_publisher = disclose.get(u'publisher', False)

        cache = obj.get(u'cache', False)

        return RouterPermissions(uri, match,
                                 call=allow_call,
                                 register=allow_register,
                                 publish=allow_publish,
                                 subscribe=allow_subscribe,
                                 disclose_caller=disclose_caller,
                                 disclose_publisher=disclose_publisher,
                                 cache=cache)