コード例 #1
0
ファイル: views.py プロジェクト: 4teamwork/ftw.bridge.proxy
    def __call__(self):
        origin = self.request.headers.get('X-BRIDGE-ORIGIN', None)
        url = self.request.url
        try:
            response = self._handle()

        except Exception, exc:
            LOG.error('%s: "%s" FAILED (%s): %s: %s' % (
                    self.request.method, origin, url,
                    type(exc).__name__, str(exc)))
            raise
コード例 #2
0
ファイル: views.py プロジェクト: treinhard/ftw.bridge.proxy
    def __call__(self):
        origin = self.request.headers.get('X-BRIDGE-ORIGIN', None)
        url = self.request.url
        try:
            response = self._handle()

        except Exception, exc:
            LOG.error('%s: "%s" FAILED (%s): %s: %s' %
                      (self.request.method, origin, url, type(exc).__name__,
                       str(exc)))
            raise
コード例 #3
0
ファイル: views.py プロジェクト: treinhard/ftw.bridge.proxy
    def __call__(self):
        if self.request.params.get('clientid'):
            clientid = self.request.params.get('clientid')
            status = self.request.params.get('status', 'online')
            client = getUtility(IClientManager).get_client_by_id(clientid)
            client.set_maintenance_mode(status == 'maintenance')
            LOG.info('manage: change status of %s to %s' % (clientid, status))
            return HTTPFound(location=self.request.headers.get('Referer'))

        return render_to_response('ftw.bridge.proxy:templates/manage.pt',
                                  {'clients': self.get_clients()},
                                  request=self.request)
コード例 #4
0
ファイル: views.py プロジェクト: 4teamwork/ftw.bridge.proxy
    def __call__(self):
        if self.request.params.get('clientid'):
            clientid = self.request.params.get('clientid')
            status = self.request.params.get('status', 'online')
            client = getUtility(IClientManager).get_client_by_id(clientid)
            client.set_maintenance_mode(status == 'maintenance')
            LOG.info('manage: change status of %s to %s' % (
                    clientid, status))
            return HTTPFound(location=self.request.headers.get('Referer'))

        return render_to_response(
            'ftw.bridge.proxy:templates/manage.pt',
            {'clients': self.get_clients()},
            request=self.request)
コード例 #5
0
    def setUp(self):
        MockerTestCase.setUp(self)

        # we do not expect requests, but lets just prevent accidental
        # requests
        self.requests = self.mocker.replace('requests')
        self.expect(self.requests.request(ARGS, KWARGS)).count(0)

        self.proxy = self.mocker.mock(Proxy, count=False)
        ProxyMock = self.mocker.mock(count=False)
        self.expect(ProxyMock(ANY)).result(self.proxy)

        sm = get_current_registry()
        sm.registerAdapter(ProxyMock, [IRequest], IProxy, name='')

        self.stream = StringIO()
        self.handler = StreamHandler(self.stream)
        self.handler.setFormatter(Formatter('%(levelname)s %(message)s'))
        LOG.addHandler(self.handler)
        self.ori_log_level = LOG.getEffectiveLevel()
        LOG.setLevel(DEBUG)
コード例 #6
0
    def setUp(self):
        MockerTestCase.setUp(self)

        # we do not expect requests, but lets just prevent accidental
        # requests
        self.requests = self.mocker.replace('requests')
        self.expect(self.requests.request(ARGS, KWARGS)).count(0)

        self.proxy = self.mocker.mock(Proxy, count=False)
        ProxyMock = self.mocker.mock(count=False)
        self.expect(ProxyMock(ANY)).result(self.proxy)

        sm = get_current_registry()
        sm.registerAdapter(ProxyMock, [IRequest], IProxy, name='')

        self.stream = StringIO()
        self.handler = StreamHandler(self.stream)
        self.handler.setFormatter(Formatter('%(levelname)s %(message)s'))
        LOG.addHandler(self.handler)
        self.ori_log_level = LOG.getEffectiveLevel()
        LOG.setLevel(DEBUG)
コード例 #7
0
 def tearDown(self):
     LOG.removeHandler(self.handler)
     LOG.setLevel(self.ori_log_level)
コード例 #8
0
 def tearDown(self):
     LOG.removeHandler(self.handler)
     LOG.setLevel(self.ori_log_level)
コード例 #9
0
ファイル: views.py プロジェクト: 4teamwork/ftw.bridge.proxy
    def __call__(self):
        origin = self.request.headers.get('X-BRIDGE-ORIGIN', None)
        url = self.request.url
        try:
            response = self._handle()

        except Exception, exc:
            LOG.error('%s: "%s" FAILED (%s): %s: %s' % (
                    self.request.method, origin, url,
                    type(exc).__name__, str(exc)))
            raise

        else:
            LOG.info('%s: "%s" %s (%s)' % (
                    self.request.method,
                    origin, response.status, url))
            return response

    def _handle(self):
        auth_manager = getAdapter(self.request, IAuthorizationManager)
        auth_manager.authorize()
        return IProxy(self.request)()


class ManageView(object):

    def __init__(self, request):
        self.request = request

    @protected
コード例 #10
0
ファイル: views.py プロジェクト: treinhard/ftw.bridge.proxy
        self.request = request

    def __call__(self):
        origin = self.request.headers.get('X-BRIDGE-ORIGIN', None)
        url = self.request.url
        try:
            response = self._handle()

        except Exception, exc:
            LOG.error('%s: "%s" FAILED (%s): %s: %s' %
                      (self.request.method, origin, url, type(exc).__name__,
                       str(exc)))
            raise

        else:
            LOG.info('%s: "%s" %s (%s)' %
                     (self.request.method, origin, response.status, url))
            return response

    def _handle(self):
        auth_manager = getAdapter(self.request, IAuthorizationManager)
        auth_manager.authorize()
        return IProxy(self.request)()


class ManageView(object):
    def __init__(self, request):
        self.request = request

    @protected
    def __call__(self):
        if self.request.params.get('clientid'):