本文整理汇总了Python中pyramid.request.Request._set_extensions方法的典型用法代码示例。如果您正苦于以下问题:Python Request._set_extensions方法的具体用法?Python Request._set_extensions怎么用?Python Request._set_extensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.request.Request
的用法示例。
在下文中一共展示了Request._set_extensions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _makeRequest
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import _set_extensions [as 别名]
def _makeRequest(self, config, environ={}):
from pyramid.request import Request
from pyramid.interfaces import IRequestExtensions
request = Request(environ)
request.registry = config.registry
request._set_extensions(config.registry.getUtility(IRequestExtensions))
return request
示例2: test_includeme
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import _set_extensions [as 别名]
def test_includeme(testconfig, icons_dir):
testconfig.get_settings()["icons_path"] = str(icons_dir)
testconfig.include(pylf.icons)
testconfig.commit()
req_exts = testconfig.registry.queryUtility(IRequestExtensions)
req = Request({})
req._set_extensions(req_exts)
assert hasattr(req, "icon_path")
icon_path = req.icon_path
assert icon_path((None, None)) == "/icons/unknown.png"
assert icon_path(("text/plain", None)) == "/icons/text-plain.png"
示例3: test_directive_get_sockjs_manager
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import _set_extensions [as 别名]
def test_directive_get_sockjs_manager(self):
self.config.include('pyramid_sockjs')
request = Request(self._environ)
request.registry = self.registry
self.registry.notify(NewRequest(request))
try:
from pyramid.interfaces import IRequestExtensions
extensions = self.registry.getUtility(IRequestExtensions)
request._set_extensions(extensions)
except ImportError:
pass
self.assertTrue(hasattr(request, 'get_sockjs_manager'))
示例4: test_get_session_manager_unknown
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import _set_extensions [as 别名]
def test_get_session_manager_unknown(self):
request = Request(self._environ)
request.registry = self.registry
self.registry.notify(NewRequest(request))
try:
from pyramid.interfaces import IRequestExtensions
extensions = self.registry.getUtility(IRequestExtensions)
request._set_extensions(extensions)
except ImportError:
pass
self.assertRaises(
KeyError, request.get_sockjs_manager, 'test')
self.config.add_sockjs_route()
self.assertRaises(
KeyError, request.get_sockjs_manager, 'test')
示例5: test_get_session_manager_default
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import _set_extensions [as 别名]
def test_get_session_manager_default(self):
import pyramid_sockjs
self.config.add_sockjs_route()
request = Request(self._environ)
request.registry = self.registry
self.registry.notify(NewRequest(request))
try:
from pyramid.interfaces import IRequestExtensions
extensions = self.registry.getUtility(IRequestExtensions)
request._set_extensions(extensions)
except ImportError:
pass
sm = request.get_sockjs_manager()
self.assertIs(self.registry.__sockjs_managers__[''], sm)
示例6: test_session_manager_route_url
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import _set_extensions [as 别名]
def test_session_manager_route_url(self):
import pyramid_sockjs
name = 'example'
self.config.add_sockjs_route(name, prefix='/chat-service')
self.config.commit()
request = Request(self._environ)
request.registry = self.registry
self.registry.notify(NewRequest(request))
try:
from pyramid.interfaces import IRequestExtensions
extensions = self.registry.getUtility(IRequestExtensions)
request._set_extensions(extensions)
except ImportError:
pass
sm = request.get_sockjs_manager(name)
self.assertEqual(
sm.route_url(request), 'http://example.com/chat-service/')