18 |
18 |
19 from cubicweb import RequestSessionMixIn, Binary |
19 from cubicweb import RequestSessionMixIn, Binary |
20 from cubicweb.dbapi import ConnectionProperties |
20 from cubicweb.dbapi import ConnectionProperties |
21 from cubicweb.common.utils import make_uid |
21 from cubicweb.common.utils import make_uid |
22 from cubicweb.server.rqlrewrite import RQLRewriter |
22 from cubicweb.server.rqlrewrite import RQLRewriter |
|
23 |
|
24 _ETYPE_PYOBJ_MAP = { bool: 'Boolean', |
|
25 int: 'Int', |
|
26 long: 'Int', |
|
27 float: 'Float', |
|
28 Decimal: 'Decimal', |
|
29 unicode: 'String', |
|
30 NoneType: None, |
|
31 Binary: 'Bytes', |
|
32 DateTimeType: 'Datetime', |
|
33 DateTimeDeltaType: 'Interval', |
|
34 } |
23 |
35 |
24 def etype_from_pyobj(value): |
36 def etype_from_pyobj(value): |
25 """guess yams type from python value""" |
37 """guess yams type from python value""" |
26 # note: |
38 # note: |
27 # * Password is not selectable so no problem) |
39 # * Password is not selectable so no problem) |
28 # * use type(value) and not value.__class__ since mx instances have no |
40 # * use type(value) and not value.__class__ since mx instances have no |
29 # __class__ attribute |
41 # __class__ attribute |
30 # * XXX Date, Time |
42 # * XXX Date, Time |
31 return {bool: 'Boolean', |
43 return _ETYPE_PYOBJ_MAP[type(value)] |
32 int: 'Int', |
|
33 long: 'Int', |
|
34 float: 'Float', |
|
35 Decimal: 'Decimal', |
|
36 unicode: 'String', |
|
37 NoneType: None, |
|
38 Binary: 'Bytes', |
|
39 DateTimeType: 'Datetime', |
|
40 DateTimeDeltaType: 'Interval', |
|
41 }[type(value)] |
|
42 |
44 |
43 def is_final(rqlst, variable, args): |
45 def is_final(rqlst, variable, args): |
44 # try to find if this is a final var or not |
46 # try to find if this is a final var or not |
45 for select in rqlst.children: |
47 for select in rqlst.children: |
46 for sol in select.solutions: |
48 for sol in select.solutions: |