fix more URI types in examples
This commit is contained in:
parent
f63ee614ca
commit
a54d0d9a36
|
@ -38,7 +38,7 @@ from autobahn.wamp.exception import ApplicationError
|
||||||
from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner
|
from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner
|
||||||
|
|
||||||
|
|
||||||
@wamp.error("com.myapp.error1")
|
@wamp.error(u"com.myapp.error1")
|
||||||
class AppError1(Exception):
|
class AppError1(Exception):
|
||||||
"""
|
"""
|
||||||
An application specific exception that is decorated with a WAMP URI,
|
An application specific exception that is decorated with a WAMP URI,
|
||||||
|
@ -69,15 +69,15 @@ class Component(ApplicationSession):
|
||||||
##
|
##
|
||||||
def checkname(name):
|
def checkname(name):
|
||||||
if name in ['foo', 'bar']:
|
if name in ['foo', 'bar']:
|
||||||
raise ApplicationError("com.myapp.error.reserved")
|
raise ApplicationError(u"com.myapp.error.reserved")
|
||||||
|
|
||||||
if name.lower() != name.upper():
|
if name.lower() != name.upper():
|
||||||
# forward positional arguments in exceptions
|
# forward positional arguments in exceptions
|
||||||
raise ApplicationError("com.myapp.error.mixed_case", name.lower(), name.upper())
|
raise ApplicationError(u"com.myapp.error.mixed_case", name.lower(), name.upper())
|
||||||
|
|
||||||
if len(name) < 3 or len(name) > 10:
|
if len(name) < 3 or len(name) > 10:
|
||||||
# forward keyword arguments in exceptions
|
# forward keyword arguments in exceptions
|
||||||
raise ApplicationError("com.myapp.error.invalid_length", min=3, max=10)
|
raise ApplicationError(u"com.myapp.error.invalid_length", min=3, max=10)
|
||||||
|
|
||||||
yield from self.register(checkname, u'com.myapp.checkname')
|
yield from self.register(checkname, u'com.myapp.checkname')
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ from autobahn.wamp.exception import ApplicationError
|
||||||
from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner
|
from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner
|
||||||
|
|
||||||
|
|
||||||
@wamp.error("com.myapp.error1")
|
@wamp.error(u"com.myapp.error1")
|
||||||
class AppError1(Exception):
|
class AppError1(Exception):
|
||||||
"""
|
"""
|
||||||
An application specific exception that is decorated with a WAMP URI,
|
An application specific exception that is decorated with a WAMP URI,
|
||||||
|
|
|
@ -53,7 +53,7 @@ class Component(ApplicationSession):
|
||||||
return x * x
|
return x * x
|
||||||
|
|
||||||
yield from self.register(slowsquare, u'com.math.slowsquare')
|
yield from self.register(slowsquare, u'com.math.slowsquare')
|
||||||
print("Registered 'com.math.slowsquare'")
|
print("Registered com.math.slowsquare")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Component(ApplicationSession):
|
||||||
print("session attached")
|
print("session attached")
|
||||||
counter = 0
|
counter = 0
|
||||||
while True:
|
while True:
|
||||||
print('backend publishing "com.myapp.topic1"', counter)
|
print('backend publishing com.myapp.topic1', counter)
|
||||||
self.publish(u'com.myapp.topic1', counter)
|
self.publish(u'com.myapp.topic1', counter)
|
||||||
counter += 1
|
counter += 1
|
||||||
yield sleep(1)
|
yield sleep(1)
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Component(ApplicationSession):
|
||||||
print("session attached")
|
print("session attached")
|
||||||
self.received = 0
|
self.received = 0
|
||||||
sub = yield self.subscribe(self.on_event, u'com.myapp.topic1')
|
sub = yield self.subscribe(self.on_event, u'com.myapp.topic1')
|
||||||
print("Subscribed to 'com.myapp.topic1' with {}".format(sub.id))
|
print("Subscribed to com.myapp.topic1 with {}".format(sub.id))
|
||||||
|
|
||||||
def on_event(self, i):
|
def on_event(self, i):
|
||||||
print("Got event: {}".format(i))
|
print("Got event: {}".format(i))
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Component(ApplicationSession):
|
||||||
exclude_me=False
|
exclude_me=False
|
||||||
)
|
)
|
||||||
publication = yield self.publish(
|
publication = yield self.publish(
|
||||||
'com.myapp.topic1', counter,
|
u'com.myapp.topic1', counter,
|
||||||
options=pub_options,
|
options=pub_options,
|
||||||
)
|
)
|
||||||
print("Published with publication ID {}".format(publication.id))
|
print("Published with publication ID {}".format(publication.id))
|
||||||
|
|
|
@ -66,15 +66,15 @@ class Component(ApplicationSession):
|
||||||
##
|
##
|
||||||
def checkname(name):
|
def checkname(name):
|
||||||
if name in ['foo', 'bar']:
|
if name in ['foo', 'bar']:
|
||||||
raise ApplicationError("com.myapp.error.reserved")
|
raise ApplicationError(u"com.myapp.error.reserved")
|
||||||
|
|
||||||
if name.lower() != name.upper():
|
if name.lower() != name.upper():
|
||||||
# forward positional arguments in exceptions
|
# forward positional arguments in exceptions
|
||||||
raise ApplicationError("com.myapp.error.mixed_case", name.lower(), name.upper())
|
raise ApplicationError(u"com.myapp.error.mixed_case", name.lower(), name.upper())
|
||||||
|
|
||||||
if len(name) < 3 or len(name) > 10:
|
if len(name) < 3 or len(name) > 10:
|
||||||
# forward keyword arguments in exceptions
|
# forward keyword arguments in exceptions
|
||||||
raise ApplicationError("com.myapp.error.invalid_length", min=3, max=10)
|
raise ApplicationError(u"com.myapp.error.invalid_length", min=3, max=10)
|
||||||
|
|
||||||
yield self.register(checkname, u'com.myapp.checkname')
|
yield self.register(checkname, u'com.myapp.checkname')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue