cubicweb/web/request.py
changeset 11767 432f87a63057
parent 11765 9cb215e833b0
child 11794 d8830e2bd2e0
equal deleted inserted replaced
11766:d8de1ac21f36 11767:432f87a63057
     1 # copyright 2003-2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2016 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    15 #
    15 #
    16 # You should have received a copy of the GNU Lesser General Public License along
    16 # You should have received a copy of the GNU Lesser General Public License along
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
    18 """abstract class for http request"""
    18 """abstract class for http request"""
    19 
    19 
    20 __docformat__ = "restructuredtext en"
       
    21 
       
    22 import time
    20 import time
    23 import random
    21 import random
    24 import base64
    22 import base64
    25 from hashlib import sha1 # pylint: disable=E0611
    23 from hashlib import sha1  # pylint: disable=E0611
    26 from calendar import timegm
    24 from calendar import timegm
    27 from datetime import date, datetime
    25 from datetime import date, datetime
    28 from warnings import warn
    26 from warnings import warn
    29 from io import BytesIO
    27 from io import BytesIO
    30 
    28 
    31 from six import PY2, binary_type, text_type, string_types
    29 from six import PY2, text_type, string_types
    32 from six.moves import http_client
    30 from six.moves import http_client
    33 from six.moves.urllib.parse import urlsplit, quote as urlquote
    31 from six.moves.urllib.parse import urlsplit, quote as urlquote
    34 from six.moves.http_cookies import SimpleCookie
    32 from six.moves.http_cookies import SimpleCookie
    35 
    33 
    36 from rql.utils import rqlvar_maker
    34 from rql.utils import rqlvar_maker
    37 
    35 
    38 from logilab.common.decorators import cached
    36 from logilab.common.decorators import cached
    39 from logilab.common.deprecation import deprecated
    37 from logilab.common.deprecation import deprecated
    40 from logilab.mtconverter import xml_escape
       
    41 
    38 
    42 from cubicweb import AuthenticationError
    39 from cubicweb import AuthenticationError
    43 from cubicweb.req import RequestSessionBase
    40 from cubicweb.req import RequestSessionBase
    44 from cubicweb.uilib import remove_html_tags, js
    41 from cubicweb.uilib import remove_html_tags, js
    45 from cubicweb.utils import HTMLHead, make_uid
    42 from cubicweb.utils import HTMLHead, make_uid
    46 from cubicweb.view import TRANSITIONAL_DOCTYPE_NOEXT
       
    47 from cubicweb.web import (INTERNAL_FIELD_VALUE, LOGGER, NothingToEdit,
    43 from cubicweb.web import (INTERNAL_FIELD_VALUE, LOGGER, NothingToEdit,
    48                           RequestError, StatusResponse)
    44                           RequestError, StatusResponse)
    49 from cubicweb.web.httpcache import get_validators
    45 from cubicweb.web.httpcache import get_validators
    50 from cubicweb.web.http_headers import Headers, Cookie, parseDateTime
    46 from cubicweb.web.http_headers import Headers, Cookie
       
    47 
    51 
    48 
    52 _MARKER = object()
    49 _MARKER = object()
       
    50 
    53 
    51 
    54 def build_cb_uid(seed):
    52 def build_cb_uid(seed):
    55     sha = sha1(('%s%s%s' % (time.time(), seed, random.random())).encode('ascii'))
    53     sha = sha1(('%s%s%s' % (time.time(), seed, random.random())).encode('ascii'))
    56     return 'cb_%s' % (sha.hexdigest())
    54     return 'cb_%s' % (sha.hexdigest())
    57 
    55 
  1011     entity_metas = _cnx_func('entity_metas')  # XXX deprecated
  1009     entity_metas = _cnx_func('entity_metas')  # XXX deprecated
  1012     entity_type = _cnx_func('entity_type')
  1010     entity_type = _cnx_func('entity_type')
  1013     source_defs = _cnx_func('source_defs')
  1011     source_defs = _cnx_func('source_defs')
  1014     get_shared_data = _cnx_func('get_shared_data')
  1012     get_shared_data = _cnx_func('get_shared_data')
  1015     set_shared_data = _cnx_func('set_shared_data')
  1013     set_shared_data = _cnx_func('set_shared_data')
  1016     describe = _cnx_func('describe') # deprecated XXX
       
  1017 
  1014 
  1018     # security #################################################################
  1015     # security #################################################################
  1019 
  1016 
  1020     security_enabled = _cnx_func('security_enabled')
  1017     security_enabled = _cnx_func('security_enabled')
  1021 
  1018