autobahn.wamp.uri


Module Contents

Classes

Pattern

A WAMP URI Pattern.

Functions

convert_starred_uri(uri)

Convert a starred URI to a standard WAMP URI and a detected matching

register(uri[, options, check_types])

Decorator for WAMP procedure endpoints.

subscribe(uri[, options, check_types])

Decorator for WAMP event handlers.

error(uri)

Decorator for WAMP error classes.

autobahn.wamp.uri.convert_starred_uri(uri: str)[source]

Convert a starred URI to a standard WAMP URI and a detected matching policy. A starred URI is one that may contain the character ‘*’ used to mark URI wildcard components or URI prefixes. Starred URIs are more comfortable / intuitive to use at the user/API level, but need to be converted for use on the wire (WAMP protocol level).

This function takes a possibly starred URI, detects the matching policy implied by stars, and returns a pair (uri, match) with any stars removed from the URI and the detected matching policy.

An URI like ‘com.example.topic1’ (without any stars in it) is detected as an exact-matching URI.

An URI like ‘com.example.*’ (with exactly one star at the very end) is detected as a prefix-matching URI on ‘com.example.’.

An URI like ‘com.*.foobar.*’ (with more than one star anywhere) is detected as a wildcard-matching URI on ‘com..foobar.’ (in this example, there are two wildcard URI components).

Note that an URI like ‘com.example.*’ is always detected as a prefix-matching URI ‘com.example.’. You cannot express a wildcard-matching URI ‘com.example.’ using the starred URI notation! A wildcard matching on ‘com.example.’ is different from prefix-matching on ‘com.example.’ (which matches a strict superset of the former!). This is one reason we don’t use starred URIs for WAMP at the protocol level.

class autobahn.wamp.uri.Pattern(uri: str, target: int, options: Optional[Union[autobahn.wamp.types.SubscribeOptions, autobahn.wamp.types.RegisterOptions]] = None, check_types: Optional[bool] = None)[source]

Bases: object

A WAMP URI Pattern.

property options

Returns the Options instance (if present) for this pattern.

Returns

None or the Options instance

Return type

None or RegisterOptions or SubscribeOptions

property uri_type

Returns the URI type of this pattern

Returns

Return type

Pattern.URI_TYPE_EXACT, Pattern.URI_TYPE_PREFIX or Pattern.URI_TYPE_WILDCARD

URI_TARGET_ENDPOINT = 1
URI_TARGET_HANDLER = 2
URI_TARGET_EXCEPTION = 3
URI_TYPE_EXACT = 1
URI_TYPE_PREFIX = 2
URI_TYPE_WILDCARD = 3
_URI_COMPONENT

Compiled regular expression for a WAMP URI component.

_URI_NAMED_COMPONENT

Compiled regular expression for a named WAMP URI component.

Note

This pattern is stricter than a general WAMP URI component since a valid Python identifier is required.

_URI_NAMED_CONVERTED_COMPONENT

Compiled regular expression for a named and type-converted WAMP URI component.

Note

This pattern is stricter than a general WAMP URI component since a valid Python identifier is required.

uri()[source]

Returns the original URI (pattern) for this pattern.

Returns

The URI (pattern), e.g. "com.myapp.product.<product:int>.update".

Return type

str

match(uri)[source]

Match the given (fully qualified) URI according to this pattern and return extracted args and kwargs.

Parameters

uri (str) – The URI to match, e.g. "com.myapp.product.123456.update".

Returns

A tuple (args, kwargs)

Return type

tuple

is_endpoint()[source]

Check if this pattern is for a procedure endpoint.

Returns

True, iff this pattern is for a procedure endpoint.

Return type

bool

is_handler()[source]

Check if this pattern is for an event handler.

Returns

True, iff this pattern is for an event handler.

Return type

bool

is_exception()[source]

Check if this pattern is for an exception.

Returns

True, iff this pattern is for an exception.

Return type

bool

autobahn.wamp.uri.register(uri: Optional[str], options: Optional[autobahn.wamp.types.RegisterOptions] = None, check_types: Optional[bool] = None)[source]

Decorator for WAMP procedure endpoints.

Parameters
  • uri (str) –

  • options (None or RegisterOptions) –

  • check_types (bool) – Enable automatic type checking against (Python 3.5+) type hints specified on the endpoint callable. Types are checked at run-time on each invocation of the endpoint callable. When a type mismatch occurs, the error is forwarded to the callee code in onUserError override method of autobahn.wamp.protocol.ApplicationSession. An error of type autobahn.wamp.exception.TypeCheckError is also raised and returned to the caller (via the router).

autobahn.wamp.uri.subscribe(uri: Optional[str], options: Optional[autobahn.wamp.types.SubscribeOptions] = None, check_types: Optional[bool] = None)[source]

Decorator for WAMP event handlers.

Parameters
  • uri (str) –

  • options (None or SubscribeOptions) –

  • check_types (bool) – Enable automatic type checking against (Python 3.5+) type hints specified on the endpoint callable. Types are checked at run-time on each invocation of the endpoint callable. When a type mismatch occurs, the error is forwarded to the callee code in onUserError override method of autobahn.wamp.protocol.ApplicationSession. An error of type autobahn.wamp.exception.TypeCheckError is also raised and returned to the caller (via the router).

autobahn.wamp.uri.error(uri: str)[source]

Decorator for WAMP error classes.