autobahn.wamp.uri¶
Classes¶
A WAMP URI Pattern. |
Functions¶
|
Convert a starred URI to a standard WAMP URI and a detected matching |
|
Decorator for WAMP error classes. |
|
Decorator for WAMP procedure endpoints. |
|
Decorator for WAMP event handlers. |
Module Contents¶
- class Pattern(uri: str, target: int, options: autobahn.wamp.types.SubscribeOptions | autobahn.wamp.types.RegisterOptions | None = None, check_types: bool | None = None)[source]¶
Bases:
objectA WAMP URI Pattern.
Todo
suffix matches
args + kwargs
uuid converter
multiple URI patterns per decorated object
classes: Pattern, EndpointPattern, ..
- _URI_NAMED_COMPONENT[source]¶
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[source]¶
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.
- is_endpoint()[source]¶
Check if this pattern is for a procedure endpoint.
- Returns:
True, iff this pattern is for a procedure endpoint.- Return type:
- is_exception()[source]¶
Check if this pattern is for an exception.
- Returns:
True, iff this pattern is for an exception.- Return type:
- is_handler()[source]¶
Check if this pattern is for an event handler.
- Returns:
True, iff this pattern is for an event handler.- Return type:
- match(uri)[source]¶
Match the given (fully qualified) URI according to this pattern and return extracted args and kwargs.
- property options[source]¶
Returns the Options instance (if present) for this pattern.
- Returns:
None or the Options instance
- Return type:
None or RegisterOptions or SubscribeOptions
- 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.
- register(uri: str | None, options: autobahn.wamp.types.RegisterOptions | None = None, check_types: bool | None = 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
endpointcallable. Types are checked at run-time on each invocation of theendpointcallable. When a type mismatch occurs, the error is forwarded to the callee code inonUserErroroverride method ofautobahn.wamp.protocol.ApplicationSession. An error of typeautobahn.wamp.exception.TypeCheckErroris also raised and returned to the caller (via the router).
- subscribe(uri: str | None, options: autobahn.wamp.types.SubscribeOptions | None = None, check_types: bool | None = 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
endpointcallable. Types are checked at run-time on each invocation of theendpointcallable. When a type mismatch occurs, the error is forwarded to the callee code inonUserErroroverride method ofautobahn.wamp.protocol.ApplicationSession. An error of typeautobahn.wamp.exception.TypeCheckErroris also raised and returned to the caller (via the router).