def check_balance_without_token(self): balance_endpoint_uri = absolute_url('balance', account_address='xxx') try: response = requests.get(balance_endpoint_uri, timeout=settings.TIMEOUT) except requests.exceptions.ConnectionError: return False return response.status_code == 403
def check_balance_with_correct_token(self): balance_endpoint_uri = absolute_url('balance', account_address='xxx') try: response = requests.get( balance_endpoint_uri, timeout=settings.TIMEOUT, headers={'Authorization': settings.API_KEY}) except requests.exceptions.ConnectionError: return False return response.status_code != 403
def process_request(self, request): if utils.absolute_url(request.path) == utils.get_identity() and \ 'application/xrds+xml' in request.META.get('HTTP_ACCEPT', ''): return views.yadis(request)
def process_response(self, request, response): if utils.absolute_url(request.path) == utils.get_identity(): response['X-XRDS-Location'] = utils.absolute_url(reverse(views.yadis)) return response
def yadis(request): return render_to_response('vooid/yadis.xml', { 'endpoint': absolute_url(reverse(endpoint)), 'identity': get_identity(), }, mimetype='application/xrds+xml')
def get_server(): return Server(Store(), absolute_url(reverse(endpoint)))
def _set_url(self, url): if self.service is not None and self.service.base_url is not None and \ not absolute_url(url): return urljoin(self.service.base_url, url) return url