本文整理匯總了Python中routes.request_config方法的典型用法代碼示例。如果您正苦於以下問題:Python routes.request_config方法的具體用法?Python routes.request_config怎麽用?Python routes.request_config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類routes
的用法示例。
在下文中一共展示了routes.request_config方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _load_config
# 需要導入模塊: import routes [as 別名]
# 或者: from routes import request_config [as 別名]
def _load_config(self, load_site_user=True):
conf = self._get_config()
assert 'ckan' not in dir() # otherwise loggers would be disabled
# We have now loaded the config. Now we can import ckan for the
# first time.
from ckan.config.environment import load_environment
load_environment(conf.global_conf, conf.local_conf)
self.registry = Registry()
self.registry.prepare()
import pylons
self.translator_obj = MockTranslator()
self.registry.register(pylons.translator, self.translator_obj)
if model.user_table.exists() and load_site_user:
# If the DB has already been initialized, create and register
# a pylons context object, and add the site user to it, so the
# auth works as in a normal web request
c = pylons.util.AttribSafeContextObj()
self.registry.register(pylons.c, c)
self.site_user = logic.get_action('get_site_user')({'ignore_auth': True}, {})
pylons.c.user = self.site_user['name']
pylons.c.userobj = model.User.get(self.site_user['name'])
## give routes enough information to run url_for
parsed = urlparse.urlparse(conf.get('ckan.site_url', 'http://0.0.0.0'))
request_config = routes.request_config()
request_config.host = parsed.netloc + parsed.path
request_config.protocol = parsed.scheme