当前位置: 首页>>代码示例>>Python>>正文


Python Request.registry方法代码示例

本文整理汇总了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
开发者ID:WouterVH,项目名称:ptah,代码行数:9,代码来源:base.py

示例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
开发者ID:7924102,项目名称:pyramid,代码行数:9,代码来源:test_view.py

示例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
开发者ID:jean,项目名称:pyramid_zope_request,代码行数:9,代码来源:tests.py

示例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
开发者ID:HorizonXP,项目名称:pyramid,代码行数:9,代码来源:test_url.py

示例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
开发者ID:develucas,项目名称:pyramid_localize,代码行数:9,代码来源:test_subscribers.py

示例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
开发者ID:fizyk,项目名称:pyramid_localize,代码行数:9,代码来源:conftest.py

示例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)
开发者ID:basco-johnkevin,项目名称:tradeorsale,代码行数:29,代码来源:test_views.py

示例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
开发者ID:podhmo,项目名称:mokehehe,代码行数:9,代码来源:test_workflow.py

示例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'))
开发者ID:runyaga,项目名称:pyramid_sockjs,代码行数:10,代码来源:test_config.py

示例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)
开发者ID:runyaga,项目名称:pyramid_sockjs,代码行数:12,代码来源:test_config.py

示例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')
开发者ID:AlanMachado,项目名称:pyramid,代码行数:12,代码来源:test_renderers.py

示例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
开发者ID:dbaty,项目名称:Brouz,代码行数:12,代码来源:test_i18n.py

示例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)
开发者ID:basco-johnkevin,项目名称:tradeorsale,代码行数:12,代码来源:test_views.py

示例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")
开发者ID:niallo,项目名称:pyramid,代码行数:13,代码来源:test_renderers.py

示例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
开发者ID:develucas,项目名称:pyramid_localize,代码行数:13,代码来源:test_tools.py


注:本文中的pyramid.request.Request.registry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。