本文整理汇总了Python中salmon.routing.Router.defaults方法的典型用法代码示例。如果您正苦于以下问题:Python Router.defaults方法的具体用法?Python Router.defaults怎么用?Python Router.defaults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类salmon.routing.Router
的用法示例。
在下文中一共展示了Router.defaults方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1:
# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import defaults [as 别名]
from salmon import queue
from salmon.routing import Router
import logging
import logging.config
import os
logging.config.fileConfig("config/logging.conf")
Router.defaults(**{})
Router.load(['app.server'])
Router.RELOAD=False
Router.LOG_EXCEPTIONS=True
Router.UNDELIVERABLE_QUEUE=queue.Queue("run/undeliverable")
示例2: to
# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import defaults [as 别名]
import jinja2
import logging
import logging.config
import os
# configure logging to go to a log file
logging.config.fileConfig("config/test_logging.conf")
# the relay host to actually send the final message to (set debug=1 to see what
# the relay is saying to the log server).
settings.relay = Relay(host=settings.relay_config['host'],
port=settings.relay_config['port'], debug=0)
settings.receiver = None
Router.defaults(**settings.router_defaults)
Router.load(settings.handlers + settings.queue_handlers)
Router.RELOAD=True
view.LOADER = jinja2.Environment(
loader=jinja2.PackageLoader(settings.template_config['dir'],
settings.template_config['module']))
# if you have pyenchant and enchant installed then the template tests will do
# spell checking for you, but you need to tell pyenchant where to find itself
if 'PYENCHANT_LIBRARY_PATH' not in os.environ:
os.environ['PYENCHANT_LIBRARY_PATH'] = '/opt/local/lib/libenchant.dylib'
示例3: simple_key_gen
# 需要导入模块: from salmon.routing import Router [as 别名]
# 或者: from salmon.routing.Router import defaults [as 别名]
from __future__ import print_function
from salmon.routing import Router, nolocking, route, route_like, state_key_generator, stateless
@state_key_generator
def simple_key_gen(module_name, message):
return module_name
# common routing capture regexes go in here, you can override them in @route
Router.defaults(host="localhost",
action="[a-zA-Z0-9]+",
list_name="[a-zA-Z.0-9]+")
@route("(list_name)-(action)@(host)")
def START(message, list_name=None, action=None, host=None):
print("START", message, list_name, action, host)
if action == 'explode':
print("EXPLODE!")
raise RuntimeError("Exploded on purpose.")
return CONFIRM
@route("(list_name)-confirm-(id_number)@(host)", id_number="[0-9]+")
def CONFIRM(message, list_name=None, id_number=None, host=None):
print("CONFIRM", message, list_name, id_number, host)
return POSTING