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
|
||||
|
||||
|
||||
@wamp.error("com.myapp.error1")
|
||||
@wamp.error(u"com.myapp.error1")
|
||||
class AppError1(Exception):
|
||||
"""
|
||||
An application specific exception that is decorated with a WAMP URI,
|
||||
@ -69,15 +69,15 @@ class Component(ApplicationSession):
|
||||
##
|
||||
def checkname(name):
|
||||
if name in ['foo', 'bar']:
|
||||
raise ApplicationError("com.myapp.error.reserved")
|
||||
raise ApplicationError(u"com.myapp.error.reserved")
|
||||
|
||||
if name.lower() != name.upper():
|
||||
# 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:
|
||||
# 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')
|
||||
|
||||
|
@ -38,7 +38,7 @@ from autobahn.wamp.exception import ApplicationError
|
||||
from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner
|
||||
|
||||
|
||||
@wamp.error("com.myapp.error1")
|
||||
@wamp.error(u"com.myapp.error1")
|
||||
class AppError1(Exception):
|
||||
"""
|
||||
An application specific exception that is decorated with a WAMP URI,
|
||||
|
@ -53,7 +53,7 @@ class Component(ApplicationSession):
|
||||
return x * x
|
||||
|
||||
yield from self.register(slowsquare, u'com.math.slowsquare')
|
||||
print("Registered 'com.math.slowsquare'")
|
||||
print("Registered com.math.slowsquare")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -43,7 +43,7 @@ class Component(ApplicationSession):
|
||||
print("session attached")
|
||||
counter = 0
|
||||
while True:
|
||||
print('backend publishing "com.myapp.topic1"', counter)
|
||||
print('backend publishing com.myapp.topic1', counter)
|
||||
self.publish(u'com.myapp.topic1', counter)
|
||||
counter += 1
|
||||
yield sleep(1)
|
||||
|
@ -44,7 +44,7 @@ class Component(ApplicationSession):
|
||||
print("session attached")
|
||||
self.received = 0
|
||||
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):
|
||||
print("Got event: {}".format(i))
|
||||
|
@ -57,7 +57,7 @@ class Component(ApplicationSession):
|
||||
exclude_me=False
|
||||
)
|
||||
publication = yield self.publish(
|
||||
'com.myapp.topic1', counter,
|
||||
u'com.myapp.topic1', counter,
|
||||
options=pub_options,
|
||||
)
|
||||
print("Published with publication ID {}".format(publication.id))
|
||||
|
@ -66,15 +66,15 @@ class Component(ApplicationSession):
|
||||
##
|
||||
def checkname(name):
|
||||
if name in ['foo', 'bar']:
|
||||
raise ApplicationError("com.myapp.error.reserved")
|
||||
raise ApplicationError(u"com.myapp.error.reserved")
|
||||
|
||||
if name.lower() != name.upper():
|
||||
# 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:
|
||||
# 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')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user