NameError: name 'unicode' is not defined
__call__
def __call__(self, environ, start_response):
# TODO(dcramer): ideally this is lazy, but the context helpers must
# support callbacks first
self.client.http_context(self.get_http_context(environ))
with common_exception_handling(environ, self):
iterable = self.application(environ, start_response)
return ClosingIterator(self, iterable, environ)
def get_http_context(self, environ):
return {
'method': environ.get('REQUEST_METHOD'),
wsgi_app
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
raise
return response(environ, start_response)
finally:
wsgi_app
ctx = self.request_context(environ)
error: t.Optional[BaseException] = None
try:
try:
ctx.push()
response = self.full_dispatch_request()
except Exception as e:
error = e
response = self.handle_exception(e)
except: # noqa: B001
error = sys.exc_info()[1]
full_dispatch_request
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
self,
rv: t.Union[ft.ResponseReturnValue, HTTPException],
full_dispatch_request
try:
request_started.send(self)
rv = self.preprocess_request()
if rv is None:
rv = self.dispatch_request()
except Exception as e:
rv = self.handle_user_exception(e)
return self.finalize_request(rv)
def finalize_request(
dispatch_request
and req.method == "OPTIONS"
):
return self.make_default_options_response()
# otherwise dispatch to the handler for that endpoint
view_args: t.Dict[str, t.Any] = req.view_args # type: ignore[assignment]
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
def full_dispatch_request(self) -> Response:
"""Dispatches the request and on top of that performs request
pre and postprocessing as well as HTTP exception catching and
error handling.
liqpay
# Init LiqPay
_liqpay = LiqPay(LIQPAY_PUBLIC_KEY, LIQPAY_PRIVATE_KEY)
# Calculate signature
signature = _liqpay.cnb_signature(dict(
amount=_payment.amount,
currency=_payment.currency,
description=_payment.description,
order_id=_payment.id,
type='buy',
cnb_signature
def cnb_signature(self, params):
params = self._prepare_params(params)
signature_values = [
self._private_key,
to_unicode(params.get("amount", u'')),
to_unicode(params.get("currency", u'')),
to_unicode(params.get("public_key", u'')),
to_unicode(params.get("order_id", u'')),
to_unicode(params.get("type", u'')),
to_unicode(params.get("description", u'')),
to_unicode
def to_unicode(s):
"""
:param s:
:return: unicode value (decoded utf-8)
"""
if isinstance(s, unicode):
return s
if isinstance(s, basestring):
return s.decode('utf-8', 'strict')
NameError: name 'unicode' is not defined
This is the Copy/Paste friendly version of the traceback.
The console is locked and needs to be unlocked by entering the PIN. You can find the PIN printed out on the standard output of your shell that runs the server.