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 |