polish docs and fix #455

This commit is contained in:
Tobias Oberstein 2017-03-26 14:40:29 +02:00
parent aad3bf4185
commit b61917aa27
4 changed files with 152 additions and 56 deletions

View File

@ -32,6 +32,7 @@ from autobahn.util import public
__all__ = (
'IObjectSerializer',
'ISerializer',
'IMessage',
'ITransport',
'ITransportHandler',
'ISession',
@ -109,10 +110,10 @@ class ISerializer(object):
"""
Serializes a WAMP message to bytes for sending over a transport.
:param message: An instance that implements :class:`autobahn.wamp.interfaces.IMessage`
:type message: obj
:param message: The WAMP message to be serialized.
:type message: object implementing :class:`autobahn.wamp.interfaces.IMessage`
:returns: A pair ``(payload, is_binary)``.
:returns: A pair ``(payload, isBinary)``.
:rtype: tuple
"""
@ -158,7 +159,8 @@ class IMessage(object):
:func:`autobahn.interfaces.ISerializer.unserialize`) into an instance
of this class.
:returns: obj -- An instance of this class.
:returns: The parsed WAMP message.
:rtype: object implementing :class:`autobahn.wamp.interfaces.IMessage`
"""
@public
@ -170,7 +172,7 @@ class IMessage(object):
serializer, return the cached representation directly.
:param serializer: The wire level serializer to use.
:type serializer: instance of :class:`autobahn.wamp.interfaces.ISerializer`
:type serializer: object implementing :class:`autobahn.wamp.interfaces.ISerializer`
:returns: The serialized bytes.
:rtype: bytes
@ -180,7 +182,7 @@ class IMessage(object):
@abc.abstractmethod
def uncache():
"""
Resets the serialization cache.
Resets the serialization cache for this message.
"""
@ -202,8 +204,8 @@ class ITransport(object):
messages may be sent. When send() is called while a previous deferred/future
has not yet fired, the send will fail immediately.
:param message: An instance that implements :class:`autobahn.wamp.interfaces.IMessage`
:type message: obj
:param message: The WAMP message to send over the transport.
:type message: object implementing :class:`autobahn.wamp.interfaces.IMessage`
:returns: obj -- A Deferred/Future
"""
@ -214,7 +216,8 @@ class ITransport(object):
"""
Check if the transport is open for messaging.
:returns: bool -- ``True``, if the transport is open.
:returns: ``True``, if the transport is open.
:rtype: bool
"""
@public
@ -303,8 +306,8 @@ class ITransportHandler(object):
is considered running and is_open() would return true, as soon as this callback
has completed successfully.
:param transport: An instance that implements :class:`autobahn.wamp.interfaces.ITransport`
:type transport: obj
:param transport: The WAMP transport.
:type transport: object implementing :class:`autobahn.wamp.interfaces.ITransport`
"""
@public
@ -315,8 +318,8 @@ class ITransportHandler(object):
should return or fire the returned deferred/future when it's done processing the message.
In particular, an implementation of this callback must not access the message afterwards.
:param message: An instance that implements :class:`autobahn.wamp.interfaces.IMessage`
:type message: obj
:param message: The WAMP message received.
:type message: object implementing :class:`autobahn.wamp.interfaces.IMessage`
"""
@public

View File

@ -117,18 +117,23 @@ def check_or_raise_uri(value, message=u"WAMP message invalid", strict=False, all
:param value: The value to check.
:type value: unicode or None
:param message: Prefix for message in exception raised when value is invalid.
:type message: unicode
:param strict: If ``True``, do a strict check on the URI (the WAMP spec SHOULD behavior).
:type strict: bool
:param allow_empty_components: If ``True``, allow empty URI components (for pattern based
subscriptions and registrations).
:type allow_empty_components: bool
:param allow_none: If ``True``, allow ``None`` for URIs.
:type allow_none: bool
:returns: The URI value (if valid).
:rtype: unicode
:raises: instance of :class:`autobahn.wamp.exception.ProtocolError`
"""
if value is None:
@ -171,11 +176,13 @@ def check_or_raise_id(value, message=u"WAMP message invalid"):
:param value: The value to check.
:type value: int
:param message: Prefix for message in exception raised when value is invalid.
:type message: unicode
:returns: The ID value (if valid).
:rtype: int
:raises: instance of :class:`autobahn.wamp.exception.ProtocolError`
"""
if type(value) not in six.integer_types:
@ -196,11 +203,13 @@ def check_or_raise_extra(value, message=u"WAMP message invalid"):
:param value: The value to check.
:type value: dict
:param message: Prefix for message in exception raised when value is invalid.
:type message: unicode
:returns: The extra dictionary (if valid).
:rtype: dict
:raises: instance of :class:`autobahn.wamp.exception.ProtocolError`
"""
if type(value) != dict:
@ -277,20 +286,28 @@ class Hello(Message):
:param realm: The URI of the WAMP realm to join.
:type realm: unicode
:param roles: The WAMP session roles and features to announce.
:type roles: dict of :class:`autobahn.wamp.role.RoleFeatures`
:param authmethods: The authentication methods to announce.
:type authmethods: list of unicode or None
:param authid: The authentication ID to announce.
:type authid: unicode or None
:param authrole: The authentication role to announce.
:type authrole: unicode or None
:param authextra: Application-specific "extra data" to be forwarded to the client.
:type authextra: arbitrary or None
:param resumable: Whether the client wants this to be a session that can be later resumed.
:type resumable: bool or None
:param resume_session: The session the client would like to resume.
:type resume_session: int or None
:param resume_token: The secure authorisation token to resume the session.
:type resume_token: unicode or None
"""
@ -333,7 +350,6 @@ class Hello(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Hello.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -493,26 +509,37 @@ class Welcome(Message):
:param session: The WAMP session ID the other peer is assigned.
:type session: int
:param roles: The WAMP roles to announce.
:type roles: dict of :class:`autobahn.wamp.role.RoleFeatures`
:param realm: The effective realm the session is joined on.
:type realm: unicode or None
:param authid: The authentication ID assigned.
:type authid: unicode or None
:param authrole: The authentication role assigned.
:type authrole: unicode or None
:param authmethod: The authentication method in use.
:type authmethod: unicode or None
:param authprovider: The authentication provided in use.
:type authprovider: unicode or None
:param authextra: Application-specific "extra data" to be forwarded to the client.
:type authextra: arbitrary or None
:param resumed: Whether the session is a resumed one.
:type resumed: bool or None
:param resumable: Whether this session can be resumed later.
:type resumable: bool or None
:param resume_token: The secure authorisation token to resume the session.
:type resume_token: unicode or None
:param custom: Implementation-specific "custom attributes" (`x_my_impl_attribute`) to be set.
:type custom: dict or None
"""
@ -561,7 +588,6 @@ class Welcome(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Welcome.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -706,6 +732,7 @@ class Abort(Message):
:param reason: WAMP or application error URI for aborting reason.
:type reason: unicode
:param message: Optional human-readable closing message, e.g. for logging purposes.
:type message: unicode or None
"""
@ -727,7 +754,6 @@ class Abort(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
##
assert(len(wmsg) > 0 and wmsg[0] == Abort.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -786,6 +812,7 @@ class Challenge(Message):
:param method: The authentication method.
:type method: unicode
:param extra: Authentication method specific information.
:type extra: dict or None
"""
@ -807,7 +834,6 @@ class Challenge(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
##
assert(len(wmsg) > 0 and wmsg[0] == Challenge.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -855,6 +881,7 @@ class Authenticate(Message):
:param signature: The signature for the authentication challenge.
:type signature: unicode
:param extra: Authentication method specific information.
:type extra: dict or None
"""
@ -876,7 +903,6 @@ class Authenticate(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Authenticate.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -929,8 +955,10 @@ class Goodbye(Message):
:param reason: Optional WAMP or application error URI for closing reason.
:type reason: unicode
:param message: Optional human-readable closing message, e.g. for logging purposes.
:type message: unicode or None
:param resumable: From the server: Whether the session is able to be resumed (true) or destroyed (false). From the client: Whether it should be resumable (true) or destroyed (false).
:type resumable: bool or None
"""
@ -954,7 +982,6 @@ class Goodbye(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
##
assert(len(wmsg) > 0 and wmsg[0] == Goodbye.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -1030,22 +1057,30 @@ class Error(Message):
:param request_type: The WAMP message type code for the original request.
:type request_type: int
:param request: The WAMP request ID of the original request (`Call`, `Subscribe`, ...) this error occurred for.
:type request: int
:param error: The WAMP or application error URI for the error that occurred.
:type error: unicode
:param args: Positional values for application-defined exception.
Must be serializable using any serializers in use.
:type args: list or None
:param kwargs: Keyword values for application-defined exception.
Must be serializable using any serializers in use.
:type kwargs: dict or None
:param payload: Alternative, transparent payload. If given, `args` and `kwargs` must be left unset.
:type payload: unicode or bytes
:param enc_algo: If using payload encryption, the algorithm used (currently, only "cryptobox" is valid).
:type enc_algo: unicode
:param enc_key: If using payload encryption, the message encryption key.
:type enc_key: unicode or binary
:param enc_serializer: If using payload encryption, the encrypted payload object serializer.
:type enc_serializer: unicode
"""
@ -1081,7 +1116,6 @@ class Error(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Error.MESSAGE_TYPE)
if len(wmsg) not in (5, 6, 7):
@ -1220,41 +1254,57 @@ class Publish(Message):
:param request: The WAMP request ID of this request.
:type request: int
:param topic: The WAMP or application URI of the PubSub topic the event should
be published to.
:type topic: unicode
:param args: Positional values for application-defined event payload.
Must be serializable using any serializers in use.
:type args: list or tuple or None
:param kwargs: Keyword values for application-defined event payload.
Must be serializable using any serializers in use.
:type kwargs: dict or None
:param payload: Alternative, transparent payload. If given, `args` and `kwargs` must be left unset.
:type payload: unicode or bytes
:param acknowledge: If True, acknowledge the publication with a success or
error response.
:type acknowledge: bool or None
:param exclude_me: If ``True``, exclude the publisher from receiving the event, even
if he is subscribed (and eligible).
:type exclude_me: bool or None
:param exclude: List of WAMP session IDs to exclude from receiving this event.
:type exclude: list of int or None
:param exclude_authid: List of WAMP authids to exclude from receiving this event.
:type exclude_authid: list of unicode or None
:param exclude_authrole: List of WAMP authroles to exclude from receiving this event.
:type exclude_authrole: list of unicode or None
:param eligible: List of WAMP session IDs eligible to receive this event.
:type eligible: list of int or None
:param eligible_authid: List of WAMP authids eligible to receive this event.
:type eligible_authid: list of unicode or None
:param eligible_authrole: List of WAMP authroles eligible to receive this event.
:type eligible_authrole: list of unicode or None
:param retain: If ``True``, request the broker retain this event.
:type retain: bool or None
:param enc_algo: If using payload encryption, the algorithm used (currently, only "cryptobox" is valid).
:type enc_algo: unicode
:param enc_key: If using payload encryption, the message encryption key.
:type enc_key: unicode or binary
:param enc_serializer: If using payload encryption, the encrypted payload object serializer.
:type enc_serializer: unicode
"""
@ -1342,7 +1392,6 @@ class Publish(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Publish.MESSAGE_TYPE)
if len(wmsg) not in (4, 5, 6):
@ -1580,6 +1629,7 @@ class Published(Message):
:param request: The request ID of the original `PUBLISH` request.
:type request: int
:param publication: The publication ID for the published event.
:type publication: int
"""
@ -1601,7 +1651,6 @@ class Published(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Published.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -1650,10 +1699,13 @@ class Subscribe(Message):
:param request: The WAMP request ID of this request.
:type request: int
:param topic: The WAMP or application URI of the PubSub topic to subscribe to.
:type topic: unicode
:param match: The topic matching method to be used for the subscription.
:type match: unicode
:param get_retained: Whether the client wants the retained message we may have along with the subscription.
:type get_retained: bool or None
"""
@ -1680,7 +1732,6 @@ class Subscribe(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Subscribe.MESSAGE_TYPE)
if len(wmsg) != 4:
@ -1754,6 +1805,7 @@ class Subscribed(Message):
:param request: The request ID of the original ``SUBSCRIBE`` request.
:type request: int
:param subscription: The subscription ID for the subscribed topic (or topic pattern).
:type subscription: int
"""
@ -1775,7 +1827,6 @@ class Subscribed(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Subscribed.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -1820,6 +1871,7 @@ class Unsubscribe(Message):
:param request: The WAMP request ID of this request.
:type request: int
:param subscription: The subscription ID for the subscription to unsubscribe from.
:type subscription: int
"""
@ -1841,7 +1893,6 @@ class Unsubscribe(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Unsubscribe.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -1890,9 +1941,11 @@ class Unsubscribed(Message):
:param request: The request ID of the original ``UNSUBSCRIBE`` request or
``0`` is router triggered unsubscribe ("router revocation signaling").
:type request: int
:param subscription: If unsubscribe was actively triggered by router, the ID
of the subscription revoked.
:type subscription: int or None
:param reason: The reason (an URI) for revocation.
:type reason: unicode or None.
"""
@ -1917,7 +1970,6 @@ class Unsubscribed(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Unsubscribed.MESSAGE_TYPE)
if len(wmsg) not in [2, 3]:
@ -1993,32 +2045,45 @@ class Event(Message):
:param subscription: The subscription ID this event is dispatched under.
:type subscription: int
:param publication: The publication ID of the dispatched event.
:type publication: int
:param args: Positional values for application-defined exception.
Must be serializable using any serializers in use.
:type args: list or tuple or None
:param kwargs: Keyword values for application-defined exception.
Must be serializable using any serializers in use.
:type kwargs: dict or None
:param payload: Alternative, transparent payload. If given, `args` and `kwargs` must be left unset.
:type payload: unicode or bytes
:type kwargs: dict or None
:param publisher: The WAMP session ID of the pubisher. Only filled if pubisher is disclosed.
:type publisher: None or int
:param publisher_authid: The WAMP authid of the pubisher. Only filled if pubisher is disclosed.
:type publisher_authid: None or unicode
:param publisher_authrole: The WAMP authrole of the pubisher. Only filled if pubisher is disclosed.
:type publisher_authrole: None or unicode
:param topic: For pattern-based subscriptions, the event MUST contain the actual topic published to.
:type topic: unicode or None
:param retained: Whether the message was retained by the broker on the topic, rather than just published.
:type retained: bool or None
:param x_acknowledged_delivery: Whether this Event should be acknowledged.
:type x_acknowledged_delivery: bool or None
:param enc_algo: If using payload encryption, the algorithm used (currently, only "cryptobox" is valid).
:type enc_algo: unicode
:param enc_key: If using payload encryption, the message encryption key.
:type enc_key: unicode or binary
:param enc_serializer: If using payload encryption, the encrypted payload object serializer.
:type enc_serializer: unicode
"""
@ -2263,7 +2328,6 @@ class EventReceived(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == EventReceived.MESSAGE_TYPE)
if len(wmsg) != 2:
@ -2322,26 +2386,35 @@ class Call(Message):
:param request: The WAMP request ID of this request.
:type request: int
:param procedure: The WAMP or application URI of the procedure which should be called.
:type procedure: unicode
:param args: Positional values for application-defined call arguments.
Must be serializable using any serializers in use.
:type args: list or tuple or None
:param kwargs: Keyword values for application-defined call arguments.
Must be serializable using any serializers in use.
:type kwargs: dict or None
:param payload: Alternative, transparent payload. If given, `args` and `kwargs` must be left unset.
:type payload: unicode or bytes
:param timeout: If present, let the callee automatically cancel
the call after this ms.
:type timeout: int or None
:param receive_progress: If ``True``, indicates that the caller wants to receive
progressive call results.
:type receive_progress: bool or None
:param enc_algo: If using payload encryption, the algorithm used (currently, only "cryptobox" is valid).
:type enc_algo: unicode
:param enc_key: If using payload encryption, the message encryption key.
:type enc_key: unicode or binary
:param enc_serializer: If using payload encryption, the encrypted payload object serializer.
:type enc_serializer: unicode
"""
@ -2385,7 +2458,6 @@ class Call(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Call.MESSAGE_TYPE)
if len(wmsg) not in (4, 5, 6):
@ -2522,6 +2594,7 @@ class Cancel(Message):
:param request: The WAMP request ID of the original `CALL` to cancel.
:type request: int
:param mode: Specifies how to cancel the call (``"skip"``, ``"abort"`` or ``"kill"``).
:type mode: unicode or None
"""
@ -2544,7 +2617,6 @@ class Cancel(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Cancel.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -2615,21 +2687,28 @@ class Result(Message):
:param request: The request ID of the original `CALL` request.
:type request: int
:param args: Positional values for application-defined event payload.
Must be serializable using any serializers in use.
:type args: list or tuple or None
:param kwargs: Keyword values for application-defined event payload.
Must be serializable using any serializers in use.
:type kwargs: dict or None
:param payload: Alternative, transparent payload. If given, `args` and `kwargs` must be left unset.
:type payload: unicode or bytes
:param progress: If ``True``, this result is a progressive call result, and subsequent
results (or a final error) will follow.
:type progress: bool or None
:param enc_algo: If using payload encryption, the algorithm used (currently, only "cryptobox" is valid).
:type enc_algo: unicode
:param enc_key: If using payload encryption, the message encryption key.
:type enc_key: unicode or binary
:param enc_serializer: If using payload encryption, the encrypted payload object serializer.
:type enc_serializer: unicode
"""
@ -2669,7 +2748,6 @@ class Result(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Result.MESSAGE_TYPE)
if len(wmsg) not in (3, 4, 5):
@ -2795,12 +2873,16 @@ class Register(Message):
:param request: The WAMP request ID of this request.
:type request: int
:param procedure: The WAMP or application URI of the RPC endpoint provided.
:type procedure: unicode
:param match: The procedure matching policy to be used for the registration.
:type match: unicode
:param invoke: The procedure invocation policy to be used for the registration.
:type invoke: unicode
:param concurrency: The (maximum) concurrency to be used for the registration.
:type concurrency: int
"""
@ -2830,7 +2912,6 @@ class Register(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Register.MESSAGE_TYPE)
if len(wmsg) != 4:
@ -2940,6 +3021,7 @@ class Registered(Message):
:param request: The request ID of the original ``REGISTER`` request.
:type request: int
:param registration: The registration ID for the registered procedure (or procedure pattern).
:type registration: int
"""
@ -2961,7 +3043,6 @@ class Registered(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Registered.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -3006,6 +3087,7 @@ class Unregister(Message):
:param request: The WAMP request ID of this request.
:type request: int
:param registration: The registration ID for the registration to unregister.
:type registration: int
"""
@ -3027,7 +3109,6 @@ class Unregister(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Unregister.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -3075,9 +3156,11 @@ class Unregistered(Message):
:param request: The request ID of the original ``UNREGISTER`` request.
:type request: int
:param registration: If unregister was actively triggered by router, the ID
of the registration revoked.
:type registration: int or None
:param reason: The reason (an URI) for revocation.
:type reason: unicode or None.
"""
@ -3102,7 +3185,6 @@ class Unregistered(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Unregistered.MESSAGE_TYPE)
if len(wmsg) not in [2, 3]:
@ -3189,33 +3271,46 @@ class Invocation(Message):
:param request: The WAMP request ID of this request.
:type request: int
:param registration: The registration ID of the endpoint to be invoked.
:type registration: int
:param args: Positional values for application-defined event payload.
Must be serializable using any serializers in use.
:type args: list or tuple or None
:param kwargs: Keyword values for application-defined event payload.
Must be serializable using any serializers in use.
:type kwargs: dict or None
:param payload: Alternative, transparent payload. If given, `args` and `kwargs` must be left unset.
:type payload: unicode or bytes
:param timeout: If present, let the callee automatically cancels
the invocation after this ms.
:type timeout: int or None
:param receive_progress: Indicates if the callee should produce progressive results.
:type receive_progress: bool or None
:param caller: The WAMP session ID of the caller. Only filled if caller is disclosed.
:type caller: None or int
:param caller_authid: The WAMP authid of the caller. Only filled if caller is disclosed.
:type caller_authid: None or unicode
:param caller_authrole: The WAMP authrole of the caller. Only filled if caller is disclosed.
:type caller_authrole: None or unicode
:param procedure: For pattern-based registrations, the invocation MUST include the actual procedure being called.
:type procedure: unicode or None
:param enc_algo: If using payload encryption, the algorithm used (currently, only "cryptobox" is valid).
:type enc_algo: unicode
:param enc_key: If using payload encryption, the message encryption key.
:type enc_key: unicode or binary
:param enc_serializer: If using payload encryption, the encrypted payload object serializer.
:type enc_serializer: unicode
"""
@ -3267,7 +3362,6 @@ class Invocation(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Invocation.MESSAGE_TYPE)
if len(wmsg) not in (4, 5, 6):
@ -3455,6 +3549,7 @@ class Interrupt(Message):
:param request: The WAMP request ID of the original ``INVOCATION`` to interrupt.
:type request: int
:param mode: Specifies how to interrupt the invocation (``"abort"`` or ``"kill"``).
:type mode: unicode or None
"""
@ -3477,7 +3572,6 @@ class Interrupt(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Interrupt.MESSAGE_TYPE)
if len(wmsg) != 3:
@ -3548,21 +3642,28 @@ class Yield(Message):
:param request: The WAMP request ID of the original call.
:type request: int
:param args: Positional values for application-defined event payload.
Must be serializable using any serializers in use.
:type args: list or tuple or None
:param kwargs: Keyword values for application-defined event payload.
Must be serializable using any serializers in use.
:type kwargs: dict or None
:param payload: Alternative, transparent payload. If given, `args` and `kwargs` must be left unset.
:type payload: unicode or bytes
:param progress: If ``True``, this result is a progressive invocation result, and subsequent
results (or a final error) will follow.
:type progress: bool or None
:param enc_algo: If using payload encryption, the algorithm used (currently, only "cryptobox" is valid).
:type enc_algo: unicode
:param enc_key: If using payload encryption, the message encryption key.
:type enc_key: unicode or binary
:param enc_serializer: If using payload encryption, the encrypted payload object serializer.
:type enc_serializer: unicode
"""
@ -3602,7 +3703,6 @@ class Yield(Message):
:returns: An instance of this class.
"""
# this should already be verified by WampSerializer.unserialize
#
assert(len(wmsg) > 0 and wmsg[0] == Yield.MESSAGE_TYPE)
if len(wmsg) not in (3, 4, 5):

View File

@ -350,13 +350,14 @@ class ApplicationSession(BaseSession):
"""
Implements :func:`autobahn.wamp.interfaces.ISession.join`
"""
# FIXME
if six.PY2 and type(realm) == str:
realm = six.u(realm)
if six.PY2 and type(authid) == str:
authid = six.u(authid)
if six.PY2 and type(authrole) == str:
authrole = six.u(authrole)
assert(realm is None or type(realm) == six.text_type)
assert(authmethods is None or type(authmethods) == list)
if type(authmethods) == list:
for authmethod in authmethods:
assert(type(authmethod) == six.text_type)
assert(authid is None or type(authid) == six.text_type)
assert(authrole is None or type(authrole) == six.text_type)
assert(authextra is None or type(authextra) == dict)
if self._session_id:
raise Exception("already joined")
@ -1140,8 +1141,6 @@ class ApplicationSession(BaseSession):
"""
Implements :func:`autobahn.wamp.interfaces.IPublisher.publish`
"""
if six.PY2 and type(topic) == str:
topic = six.u(topic)
assert(type(topic) == six.text_type)
if not self._transport:
@ -1216,8 +1215,6 @@ class ApplicationSession(BaseSession):
Implements :func:`autobahn.wamp.interfaces.ISubscriber.subscribe`
"""
assert((callable(handler) and topic is not None) or hasattr(handler, '__class__'))
if topic and six.PY2 and type(topic) == str:
topic = six.u(topic)
assert(topic is None or type(topic) == six.text_type)
assert(options is None or isinstance(options, types.SubscribeOptions))
@ -1297,9 +1294,7 @@ class ApplicationSession(BaseSession):
"""
Implements :func:`autobahn.wamp.interfaces.ICaller.call`
"""
if six.PY2 and type(procedure) == str:
procedure = six.u(procedure)
assert(isinstance(procedure, six.text_type))
assert(type(procedure) == six.text_type)
if not self._transport:
raise exception.TransportLost()
@ -1375,8 +1370,6 @@ class ApplicationSession(BaseSession):
Implements :func:`autobahn.wamp.interfaces.ICallee.register`
"""
assert((callable(endpoint) and procedure is not None) or hasattr(endpoint, '__class__'))
if procedure and six.PY2 and type(procedure) == str:
procedure = six.u(procedure)
assert(procedure is None or type(procedure) == six.text_type)
assert(options is None or isinstance(options, types.RegisterOptions))

View File

@ -436,7 +436,7 @@ class SubscribeOptions(object):
:type get_retained: bool or None
"""
assert(match is None or (type(match) == six.text_type and match in [u'exact', u'prefix', u'wildcard']))
assert(details_arg is None or type(details_arg) == str)
assert(details_arg is None or type(details_arg) == str) # yes, "str" is correct here, since this is about Python identifiers!
assert(get_retained is None or type(get_retained) is bool)
self.match = match
@ -670,7 +670,7 @@ class RegisterOptions(object):
assert(match is None or (type(match) == six.text_type and match in [u'exact', u'prefix', u'wildcard']))
assert(invoke is None or (type(invoke) == six.text_type and invoke in [u'single', u'first', u'last', u'roundrobin', u'random']))
assert(concurrency is None or (type(concurrency) in six.integer_types and concurrency > 0))
assert(details_arg is None or type(details_arg) == str)
assert(details_arg is None or type(details_arg) == str) # yes, "str" is correct here, since this is about Python identifiers!
self.match = match
self.invoke = invoke