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
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
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)
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)
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)
def tearDown(self): LOG.removeHandler(self.handler) LOG.setLevel(self.ori_log_level)
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
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'):