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


Python request.Request类代码示例

本文整理汇总了Python中pyramid.request.Request的典型用法代码示例。如果您正苦于以下问题:Python Request类的具体用法?Python Request怎么用?Python Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _makeRequest

 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,代码行数:7,代码来源:test_view.py

示例2: _makeRequest

 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,代码行数:7,代码来源:test_workflow.py

示例3: _makeOne

 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,代码行数:7,代码来源:test_url.py

示例4: test_items_delete

    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,代码行数:27,代码来源:test_views.py

示例5: filemonitoring

    def filemonitoring(self):
        log = logging.getLogger(__name__)
        if self._request.params:
            # TODO: add this information to the file
            md5_enabled = True if 'withmd5' in self._request.params and self._request.params['withmd5'] == '0' else False
            all_files = self._request.params.getall('file')

            complete_file, filenames, folders = self._get_monitored_files(self._request.params['folder'] + '/')

            with transaction.manager:
                for f in all_files:
                    if f in complete_file:
                        log.debug('Skipping file {0}, because it is already monitored'.format(f))
                        continue
                    (path, filename) = os.path.split(f)
                    dbobj = MonitoredFile(path, filename, f)
                    DBSession.add(dbobj)
                DBSession.commit()
            files_not_mentioned = [c for c in complete_file if c not in all_files]
            # TODO: decide on this
            log.info('TODO: Still have to decide whether files which are not selected should be deleted or not.'
                     'Affected files would be: {0}'.format(files_not_mentioned))
        else:
            log.info('Got an empty request, going to redirect to start page')
            subreq = Request.blank('/')
            return self._request.invoke_subrequest(subreq)

        subreq = Request.blank(self._request.route_path('filebrowser'),
                               POST=dict(folder=self._request.params['folder'],
                                         currentfolder=self._request.params['currentfolder'],
                                         pathdescription='abs'))
        return self._request.invoke_subrequest(subreq)
开发者ID:meyerjo,项目名称:ClusterJobMonitor,代码行数:32,代码来源:fileviews.py

示例6: _makeRequest

 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,代码行数:7,代码来源:base.py

示例7: test_create_update

    def test_create_update(self):
        from papyrus.protocol import Protocol
        from pyramid.request import Request
        from geojson import Feature, FeatureCollection
        from shapely.geometry import Point

        MappedClass = self._get_mapped_class()

        # a mock session specific to this test
        class MockSession(object):
            def query(self, mapped_class):
                return {'a': mapped_class(Feature(id='a')),
                        'b': mapped_class(Feature(id='b'))}
            def flush(self):
                pass

        proto = Protocol(MockSession, MappedClass, 'geom')

        # we need an actual Request object here, for body to do its job
        request = Request({})
        request.method = 'POST'
        request.body = '{"type": "FeatureCollection", "features": [{"type": "Feature", "id": "a", "properties": {"text": "foo"}, "geometry": {"type": "Point", "coordinates": [45, 5]}}, {"type": "Feature", "id": "b", "properties": {"text": "bar"}, "geometry": {"type": "Point", "coordinates": [46, 6]}}]}'
        features = proto.create(request)

        self.assertTrue(isinstance(features, FeatureCollection))
        self.assertEqual(len(features.features), 2)
        self.assertEqual(features.features[0].id, 'a')
        self.assertEqual(features.features[0].text, 'foo')
        self.assertTrue(features.features[0].geom.shape.equals(Point(45, 5)))
        self.assertEqual(features.features[1].id, 'b')
        self.assertEqual(features.features[1].text, 'bar')
        self.assertTrue(features.features[1].geom.shape.equals(Point(46, 6)))
开发者ID:sbrunner,项目名称:papyrus,代码行数:32,代码来源:test_protocol.py

示例8: request_fake

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,代码行数:7,代码来源:conftest.py

示例9: _create_request

    def _create_request(self):
        from pyramid.request import Request
        from c2cgeoportal import get_user_from_request

        request = Request({})
        request.set_property(get_user_from_request, name="user", reify=True)
        return request
开发者ID:DavMerca007,项目名称:c2cgeoportal,代码行数:7,代码来源:test_groups_finder.py

示例10: testGetWsdl

    def testGetWsdl(self):
        """Simple test for serving of WSDL by spyne through pyramid route"""
        application = PyramidApplication(
            Application([self.HelloWorldService],
                        tns='spyne.examples.hello',
                        in_protocol=Soap11(validator='lxml'),
                        out_protocol=Soap11()))

        config = Configurator(settings={'debug_all': True})
        config.add_route('home', '/')
        config.add_view(application, route_name='home')
        wsgi_app = validator(config.make_wsgi_app())

        env = {
            'SCRIPT_NAME': '',
            'REQUEST_METHOD': 'GET',
            'PATH_INFO': '/',
            'QUERY_STRING': 'wsdl',
        }
        setup_testing_defaults(env)

        request = Request(env)
        resp = request.get_response(wsgi_app)
        self.assert_(resp.status.startswith("200 "))
        node = etree.XML(resp.body)  # will throw exception if non well formed
开发者ID:knoxsp,项目名称:spyne,代码行数:25,代码来源:test_pyramid.py

示例11: _makeRequest

    def _makeRequest(self, environ=None):
        if environ is None:
            environ = {}
        request = Request(environ)
        request.registry = self.config.registry

        return request
开发者ID:develucas,项目名称:pyramid_localize,代码行数:7,代码来源:test_subscribers.py

示例12: worker

 def worker(self, sem, q):
     log.info('Entering chapmand worker thread')
     while not self._shutdown:
         try:
             msg, state = q.get(timeout=0.25)
         except Empty:
             continue
         try:
             log.info('Received %r', msg)
             task = Task.from_state(state)
             # task.handle(msg, 25)
             if task.path:
                 req = Request.blank(task.path, method='CHAPMAN')
             else:
                 req = Request.blank(self._chapman_path, method='CHAPMAN')
             req.registry = self._registry
             req.environ['chapmand.task'] = task
             req.environ['chapmand.message'] = msg
             for x in self._app(req.environ, lambda *a,**kw:None):
                 pass
         except Exception as err:
             exc_log.exception('Unexpected error in worker thread: %r', err)
             time.sleep(self._sleep)
         finally:
             self._num_active_messages -= 1
             sem.release()
     log.info('Exiting chapmand worker thread')
开发者ID:synappio,项目名称:chapman,代码行数:27,代码来源:worker.py

示例13: _callFUT

 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,代码行数:7,代码来源:tests.py

示例14: __init__

    def __init__(self, *args, **kw):
        _Request.__init__(self, *args, **kw)

        self.features = self.DEFAULT_FEATURES.copy()

        # FIXME: Is there a cleaner place to put this?
        self.add_finished_callback(_teardown_session)
开发者ID:shazow,项目名称:pyramid-sampleapp,代码行数:7,代码来源:request.py

示例15: test_directive_get_sockjs_manager

    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,代码行数:8,代码来源:test_config.py


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