cubicweb/server/ssplanner.py
changeset 12567 26744ad37953
parent 12248 6350e0a482d5
child 12756 d91c229de97f
equal deleted inserted replaced
12566:6b3523f81f42 12567:26744ad37953
    14 # details.
    14 # details.
    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 """plan execution of rql queries on a single source"""
    18 """plan execution of rql queries on a single source"""
    19 
       
    20 from six import text_type
       
    21 
    19 
    22 from rql.stmts import Union, Select
    20 from rql.stmts import Union, Select
    23 from rql.nodes import Constant, Relation
    21 from rql.nodes import Constant, Relation
    24 
    22 
    25 from cubicweb import QueryError
    23 from cubicweb import QueryError
    53             if isinstance(rhs, Constant) and not rhs.uid:
    51             if isinstance(rhs, Constant) and not rhs.uid:
    54                 # add constant values to entity def
    52                 # add constant values to entity def
    55                 value = rhs.eval(plan.args)
    53                 value = rhs.eval(plan.args)
    56                 eschema = edef.entity.e_schema
    54                 eschema = edef.entity.e_schema
    57                 attrtype = eschema.subjrels[rtype].objects(eschema)[0]
    55                 attrtype = eschema.subjrels[rtype].objects(eschema)[0]
    58                 if attrtype == 'Password' and isinstance(value, text_type):
    56                 if attrtype == 'Password' and isinstance(value, str):
    59                     value = value.encode('UTF8')
    57                     value = value.encode('UTF8')
    60                 edef.edited_attribute(rtype, value)
    58                 edef.edited_attribute(rtype, value)
    61             elif str(rhs) in to_build:
    59             elif str(rhs) in to_build:
    62                 # create a relation between two newly created variables
    60                 # create a relation between two newly created variables
    63                 plan.add_relation_def((edef, rtype, to_build[rhs.name]))
    61                 plan.add_relation_def((edef, rtype, to_build[rhs.name]))