equal
deleted
inserted
replaced
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 """plan execution of rql queries on a single source""" |
18 """plan execution of rql queries on a single source""" |
19 |
19 |
20 __docformat__ = "restructuredtext en" |
20 __docformat__ = "restructuredtext en" |
|
21 |
|
22 from six import text_type |
21 |
23 |
22 from rql.stmts import Union, Select |
24 from rql.stmts import Union, Select |
23 from rql.nodes import Constant, Relation |
25 from rql.nodes import Constant, Relation |
24 |
26 |
25 from cubicweb import QueryError |
27 from cubicweb import QueryError |
52 if isinstance(rhs, Constant) and not rhs.uid: |
54 if isinstance(rhs, Constant) and not rhs.uid: |
53 # add constant values to entity def |
55 # add constant values to entity def |
54 value = rhs.eval(plan.args) |
56 value = rhs.eval(plan.args) |
55 eschema = edef.entity.e_schema |
57 eschema = edef.entity.e_schema |
56 attrtype = eschema.subjrels[rtype].objects(eschema)[0] |
58 attrtype = eschema.subjrels[rtype].objects(eschema)[0] |
57 if attrtype == 'Password' and isinstance(value, unicode): |
59 if attrtype == 'Password' and isinstance(value, text_type): |
58 value = value.encode('UTF8') |
60 value = value.encode('UTF8') |
59 edef.edited_attribute(rtype, value) |
61 edef.edited_attribute(rtype, value) |
60 elif str(rhs) in to_build: |
62 elif str(rhs) in to_build: |
61 # create a relation between two newly created variables |
63 # create a relation between two newly created variables |
62 plan.add_relation_def((edef, rtype, to_build[rhs.name])) |
64 plan.add_relation_def((edef, rtype, to_build[rhs.name])) |