本文整理汇总了Python中pyramid.request.Request.registry方法的典型用法代码示例。如果您正苦于以下问题:Python Request.registry方法的具体用法?Python Request.registry怎么用?Python Request.registry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.request.Request
的用法示例。
在下文中一共展示了Request.registry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _makeRequest
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def _makeRequest(self, environ=None):
from pyramid.request import Request
if environ is None:
environ = self._makeEnviron()
request = Request(environ)
request.registry = self.p_config.registry
return request
示例2: _makeRequest
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def _makeRequest(self, **environ):
from pyramid.request import Request
from pyramid.registry import Registry
environ = self._makeEnviron(**environ)
request = Request(environ)
request.registry = Registry()
return request
示例3: _callFUT
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def _callFUT(self, environ):
from pyramid.request import Request
request = Request(environ)
request.registry = self.config.registry
from pyramid_zope_request import PyramidPublisherRequest
rv = PyramidPublisherRequest(request)
return rv
示例4: _makeOne
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def _makeOne(self):
from pyramid.url import URLMethodsMixin
class Request(URLMethodsMixin):
application_url = 'http://example.com:5432'
request = Request()
request.registry = self.config.registry
return request
示例5: _makeRequest
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def _makeRequest(self, environ=None):
if environ is None:
environ = {}
request = Request(environ)
request.registry = self.config.registry
return request
示例6: request_fake
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def request_fake():
"""Create request with fake i18n subscribers on."""
config = testing.setUp()
config.scan('pyramid_localize.subscribers.fake')
request = Request({})
request.registry = config.registry
return request
示例7: test_items_delete
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def test_items_delete(self):
"""
Test deleting an item.
"""
# first create an item
self._create_item_status()
payload = {"name": "Macbook Air", "type": "TRADE", "quantity": "1",
"price": "", "description": "Lightweight lappy.",
"reason": "", "is_draft": "y", "uuid": str(uuid.uuid4())}
request = Request({}, method='POST', body=json.dumps(payload))
request.registry = self.config.registry
response = items(request)
self.assertEqual(response.status_code, 200)
self.assertEqual(DBSession.query(Item).count(), 1)
# try retrieving the newly added item
item = DBSession.query(Item).first()
# now send a delete request
request.method = 'DELETE'
request.matchdict = {'id': item.id}
request.body = None
items(request)
self.assertEqual(response.status_code, 200)
self.assertEqual(DBSession.query(Item).count(), 0)
示例8: _makeRequest
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [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
示例9: test_directive_get_sockjs_manager
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [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))
self.assertTrue(hasattr(request, 'get_sockjs_manager'))
示例10: test_get_session_manager_default
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [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))
sm = request.get_sockjs_manager()
self.assertIs(self.registry.__sockjs_managers__[''], sm)
示例11: test__make_response_with_real_request
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def test__make_response_with_real_request(self):
# functional
from pyramid.request import Request
request = Request({})
request.registry = self.config.registry
request.response.status = '406 You Lose'
helper = self._makeOne('loo.foo')
response = helper._make_response('abc', request)
self.assertEqual(response.status, '406 You Lose')
self.assertEqual(response.body, b'abc')
示例12: _make_one
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def _make_one(self, v=_no_header):
from pyramid.request import Request
r = Request(environ={})
class FakeRegistry(object):
settings = {'pyramid.available_languages': 'en fr'}
r.registry = FakeRegistry()
if v is not _no_header:
r.headers['Accept-Language'] = v
return r
示例13: test_item_image_delete_fail
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def test_item_image_delete_fail(self):
"""
Test deletion of non-existent image via DELETE request.
"""
# send DELETE request
request = Request({}, method='DELETE')
request.matchdict = {'id': 1}
request.registry = self.config.registry
self.assertRaises(HTTPBadRequest, item_images, None, request)
示例14: test__make_response_with_real_request
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def test__make_response_with_real_request(self):
# functional
from pyramid.request import Request
request = Request({})
request.registry = self.config.registry
request.response.status = "406 You Lose"
helper = self._makeOne("loo.foo")
response = helper._make_response("abc", request)
self.assertEqual(response.status, "406 You Lose")
self.assertEqual(response.body, "abc")
示例15: _makeRequest
# 需要导入模块: from pyramid.request import Request [as 别名]
# 或者: from pyramid.request.Request import registry [as 别名]
def _makeRequest(self, environ=None):
if environ is None:
environ = {}
request = Request(environ)
request.registry = self.config.registry
request.config = Mock()
mock_configuration = {
'localize.locales.available': ['en', 'pl', 'de', 'cz']}
request.config.configure_mock(**mock_configuration)
set_localizer(request)
return request