/usr/lib/python2.7/dist-packages/autobahn/wamp/request.py is in python-autobahn 17.10.1+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | ###############################################################################
#
# The MIT License (MIT)
#
# Copyright (c) Crossbar.io Technologies GmbH
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
###############################################################################
from __future__ import absolute_import
__all__ = (
'Publication',
'Subscription',
'Handler',
'Registration',
'Endpoint',
'PublishRequest',
'SubscribeRequest',
'UnsubscribeRequest',
'CallRequest',
'InvocationRequest',
'RegisterRequest',
'UnregisterRequest',
)
class Publication(object):
"""
Object representing a publication (feedback from publishing an event when doing
an acknowledged publish).
"""
__slots__ = ('id', 'was_encrypted')
def __init__(self, publication_id, was_encrypted):
"""
:param publication_id: The publication ID of the published event.
:type publication_id: int
:param was_encrypted: Flag indicating whether the app payload was encrypted.
:type was_encrypted: bool
"""
self.id = publication_id
self.was_encrypted = was_encrypted
def __str__(self):
return "Publication(id={0}, was_encrypted={1})".format(self.id, self.was_encrypted)
class Subscription(object):
"""
Object representing a handler subscription.
"""
__slots__ = ('id', 'topic', 'active', 'session', 'handler')
def __init__(self, subscription_id, topic, session, handler):
"""
:param subscription_id: The subscription ID.
:type subscription_id: int
:param topic: The subscription URI or URI pattern.
:type topic: str
:param session: The ApplicationSession this subscription is living on.
:type session: instance of ApplicationSession
:param handler: The user event callback.
:type handler: callable
"""
self.id = subscription_id
self.topic = topic
self.active = True
self.session = session
self.handler = handler
def unsubscribe(self):
"""
Unsubscribe this subscription.
"""
if self.active:
return self.session._unsubscribe(self)
else:
raise Exception("subscription no longer active")
def __str__(self):
return "Subscription(id={0}, is_active={1})".format(self.id, self.active)
class Handler(object):
"""
Object representing an event handler attached to a subscription.
"""
__slots__ = ('fn', 'obj', 'details_arg')
def __init__(self, fn, obj=None, details_arg=None):
"""
:param fn: The event handler function to be called.
:type fn: callable
:param obj: The (optional) object upon which to call the function.
:type obj: obj or None
:param details_arg: The keyword argument under which event details should be provided.
:type details_arg: str or None
"""
self.fn = fn
self.obj = obj
self.details_arg = details_arg
class Registration(object):
"""
Object representing a registration.
"""
__slots__ = ('id', 'active', 'session', 'procedure', 'endpoint')
def __init__(self, session, registration_id, procedure, endpoint):
"""
:param id: The registration ID.
:type id: int
:param active: Flag indicating whether this registration is active.
:type active: bool
:param procedure: The procedure URI or URI pattern.
:type procedure: callable
:param endpoint: The user callback.
:type endpoint: callable
"""
self.id = registration_id
self.active = True
self.session = session
self.procedure = procedure
self.endpoint = endpoint
def unregister(self):
"""
"""
if self.active:
return self.session._unregister(self)
else:
raise Exception("registration no longer active")
class Endpoint(object):
"""
Object representing an procedure endpoint attached to a registration.
"""
__slots__ = ('fn', 'obj', 'details_arg')
def __init__(self, fn, obj=None, details_arg=None):
"""
:param fn: The endpoint procedure to be called.
:type fn: callable
:param obj: The (optional) object upon which to call the function.
:type obj: obj or None
:param details_arg: The keyword argument under which call details should be provided.
:type details_arg: str or None
"""
self.fn = fn
self.obj = obj
self.details_arg = details_arg
class Request(object):
"""
Object representing an outstanding request, such as for subscribe/unsubscribe,
register/unregister or call/publish.
"""
__slots__ = ('request_id', 'on_reply')
def __init__(self, request_id, on_reply):
"""
:param request_id: The WAMP request ID.
:type request_id: int
:param on_reply: The Deferred/Future to be fired when the request returns.
:type on_reply: Deferred/Future
"""
self.request_id = request_id
self.on_reply = on_reply
class PublishRequest(Request):
"""
Object representing an outstanding request to publish (acknowledged) an event.
"""
__slots__ = ('was_encrypted')
def __init__(self, request_id, on_reply, was_encrypted):
"""
:param request_id: The WAMP request ID.
:type request_id: int
:param on_reply: The Deferred/Future to be fired when the request returns.
:type on_reply: Deferred/Future
:param was_encrypted: Flag indicating whether the app payload was encrypted.
:type was_encrypted: bool
"""
Request.__init__(self, request_id, on_reply)
self.was_encrypted = was_encrypted
class SubscribeRequest(Request):
"""
Object representing an outstanding request to subscribe to a topic.
"""
__slots__ = ('handler', 'topic')
def __init__(self, request_id, topic, on_reply, handler):
"""
:param request_id: The WAMP request ID.
:type request_id: int
:param topic: The topic URI being subscribed to.
:type topic: unicode
:param on_reply: The Deferred/Future to be fired when the request returns.
:type on_reply: Deferred/Future
:param handler: WAMP call options that are in use for this call.
:type handler: callable
"""
Request.__init__(self, request_id, on_reply)
self.topic = topic
self.handler = handler
class UnsubscribeRequest(Request):
"""
Object representing an outstanding request to unsubscribe a subscription.
"""
__slots__ = ('subscription_id',)
def __init__(self, request_id, on_reply, subscription_id):
"""
"""
Request.__init__(self, request_id, on_reply)
self.subscription_id = subscription_id
class CallRequest(Request):
"""
Object representing an outstanding request to call a procedure.
"""
__slots__ = ('procedure', 'options',)
def __init__(self, request_id, procedure, on_reply, options):
"""
:param request_id: The WAMP request ID.
:type request_id: int
:param on_reply: The Deferred/Future to be fired when the request returns.
:type on_reply: Deferred/Future
:param options: WAMP call options that are in use for this call.
:type options: dict
"""
Request.__init__(self, request_id, on_reply)
self.procedure = procedure
self.options = options
class InvocationRequest(Request):
"""
Object representing an outstanding request to invoke an endpoint.
"""
class RegisterRequest(Request):
"""
Object representing an outstanding request to register a procedure.
"""
__slots__ = ('procedure', 'endpoint',)
def __init__(self, request_id, on_reply, procedure, endpoint):
"""
"""
Request.__init__(self, request_id, on_reply)
self.procedure = procedure
self.endpoint = endpoint
class UnregisterRequest(Request):
"""
Object representing an outstanding request to unregister a registration.
"""
__slots__ = ('registration_id',)
def __init__(self, request_id, on_reply, registration_id):
"""
"""
Request.__init__(self, request_id, on_reply)
self.registration_id = registration_id
|