28 from warnings import warn |
28 from warnings import warn |
29 |
29 |
30 from logilab.common.deprecation import deprecated |
30 from logilab.common.deprecation import deprecated |
31 from logilab.common.textutils import unormalize |
31 from logilab.common.textutils import unormalize |
32 from logilab.common.registry import objectify_predicate |
32 from logilab.common.registry import objectify_predicate |
33 from rql import CoercionError |
33 |
34 from rql.nodes import ETYPE_PYOBJ_MAP, etype_from_pyobj |
34 from cubicweb import UnknownEid, QueryError, schema |
35 from yams import BASE_TYPES |
|
36 |
|
37 from cubicweb import Binary, UnknownEid, QueryError, schema |
|
38 from cubicweb.req import RequestSessionBase |
35 from cubicweb.req import RequestSessionBase |
39 from cubicweb.dbapi import ConnectionProperties |
36 from cubicweb.dbapi import ConnectionProperties |
40 from cubicweb.utils import make_uid, RepeatList |
37 from cubicweb.utils import make_uid |
41 from cubicweb.rqlrewrite import RQLRewriter |
38 from cubicweb.rqlrewrite import RQLRewriter |
42 from cubicweb.server import ShuttingDown |
39 from cubicweb.server import ShuttingDown |
43 from cubicweb.server.edition import EditedEntity |
40 from cubicweb.server.edition import EditedEntity |
44 |
41 |
45 |
|
46 ETYPE_PYOBJ_MAP[Binary] = 'Bytes' |
|
47 |
42 |
48 NO_UNDO_TYPES = schema.SCHEMA_TYPES.copy() |
43 NO_UNDO_TYPES = schema.SCHEMA_TYPES.copy() |
49 NO_UNDO_TYPES.add('CWCache') |
44 NO_UNDO_TYPES.add('CWCache') |
50 # is / is_instance_of are usually added by sql hooks except when using |
45 # is / is_instance_of are usually added by sql hooks except when using |
51 # dataimport.NoHookRQLObjectStore, and we don't want to record them |
46 # dataimport.NoHookRQLObjectStore, and we don't want to record them |
52 # anyway in the later case |
47 # anyway in the later case |
53 NO_UNDO_TYPES.add('is') |
48 NO_UNDO_TYPES.add('is') |
54 NO_UNDO_TYPES.add('is_instance_of') |
49 NO_UNDO_TYPES.add('is_instance_of') |
55 NO_UNDO_TYPES.add('cw_source') |
50 NO_UNDO_TYPES.add('cw_source') |
56 # XXX rememberme,forgotpwd,apycot,vcsfile |
51 # XXX rememberme,forgotpwd,apycot,vcsfile |
57 |
|
58 def _make_description(selected, args, solution): |
|
59 """return a description for a result set""" |
|
60 description = [] |
|
61 for term in selected: |
|
62 description.append(term.get_type(solution, args)) |
|
63 return description |
|
64 |
|
65 def selection_idx_type(i, rqlst, args): |
|
66 """try to return type of term at index `i` of the rqlst's selection""" |
|
67 for select in rqlst.children: |
|
68 term = select.selection[i] |
|
69 for solution in select.solutions: |
|
70 try: |
|
71 ttype = term.get_type(solution, args) |
|
72 if ttype is not None: |
|
73 return ttype |
|
74 except CoercionError: |
|
75 return None |
|
76 |
52 |
77 @objectify_predicate |
53 @objectify_predicate |
78 def is_user_session(cls, req, **kwargs): |
54 def is_user_session(cls, req, **kwargs): |
79 """repository side only predicate returning 1 if the session is a regular |
55 """repository side only predicate returning 1 if the session is a regular |
80 user session and not an internal session |
56 user session and not an internal session |