Пример #1
0
 def before_request():
     try:
         session['cart_id']
     except:
         u = uuid.uuid4()
         user_agent = request.headers.get('User-Agent')
         if user_agent is not None:
             user_agent = user_agent.encode('utf-8')
         base = 'cart: {0}|{1}|{2}'.format(_get_remote_addr(), user_agent, u)
         if str is bytes:
             base = text_type(base, 'utf-8', errors='replace')  # pragma: no cover
         h = sha512()
         h.update(base.encode('utf8'))
         session['cart_id'] = h.hexdigest()
Пример #2
0
def get_remote_addr():
    return to_unicode(_get_remote_addr())