server/session.py
changeset 5082 d6fd82a5a4e8
parent 5074 bc481dab93d4
child 5108 8495d580a580
equal deleted inserted replaced
5052:c9dbd95333f7 5082:d6fd82a5a4e8
    19 from yams import BASE_TYPES
    19 from yams import BASE_TYPES
    20 
    20 
    21 from cubicweb import Binary, UnknownEid, schema
    21 from cubicweb import Binary, UnknownEid, schema
    22 from cubicweb.req import RequestSessionBase
    22 from cubicweb.req import RequestSessionBase
    23 from cubicweb.dbapi import ConnectionProperties
    23 from cubicweb.dbapi import ConnectionProperties
    24 from cubicweb.utils import make_uid
    24 from cubicweb.utils import make_uid, RepeatList
    25 from cubicweb.rqlrewrite import RQLRewriter
    25 from cubicweb.rqlrewrite import RQLRewriter
    26 
    26 
    27 ETYPE_PYOBJ_MAP[Binary] = 'Bytes'
    27 ETYPE_PYOBJ_MAP[Binary] = 'Bytes'
    28 
    28 
    29 NO_UNDO_TYPES = schema.SCHEMA_TYPES.copy()
    29 NO_UNDO_TYPES = schema.SCHEMA_TYPES.copy()
    30 NO_UNDO_TYPES.add('CWCache')
    30 NO_UNDO_TYPES.add('CWCache')
       
    31 # is / is_instance_of are usually added by sql hooks except when using
       
    32 # dataimport.NoHookRQLObjectStore, and we don't want to record them
       
    33 # anyway in the later case
       
    34 NO_UNDO_TYPES.add('is')
       
    35 NO_UNDO_TYPES.add('is_instance_of')
    31 # XXX rememberme,forgotpwd,apycot,vcsfile
    36 # XXX rememberme,forgotpwd,apycot,vcsfile
    32 
    37 
    33 def is_final(rqlst, variable, args):
    38 def is_final(rqlst, variable, args):
    34     # try to find if this is a final var or not
    39     # try to find if this is a final var or not
    35     for select in rqlst.children:
    40     for select in rqlst.children:
   827         if len(rqlst.children) == 1 and len(rqlst.children[0].solutions) == 1:
   832         if len(rqlst.children) == 1 and len(rqlst.children[0].solutions) == 1:
   828             # easy, all lines are identical
   833             # easy, all lines are identical
   829             selected = rqlst.children[0].selection
   834             selected = rqlst.children[0].selection
   830             solution = rqlst.children[0].solutions[0]
   835             solution = rqlst.children[0].solutions[0]
   831             description = _make_description(selected, args, solution)
   836             description = _make_description(selected, args, solution)
   832             return [tuple(description)] * len(result)
   837             return RepeatList(len(result), tuple(description))
   833         # hard, delegate the work :o)
   838         # hard, delegate the work :o)
   834         return self.manual_build_descr(rqlst, args, result)
   839         return self.manual_build_descr(rqlst, args, result)
   835 
   840 
   836     def manual_build_descr(self, rqlst, args, result):
   841     def manual_build_descr(self, rqlst, args, result):
   837         """build a description for a given result by analysing each row
   842         """build a description for a given result by analysing each row
   856             else:
   861             else:
   857                 # sample etype
   862                 # sample etype
   858                 etype = rqlst.children[0].solutions[0]
   863                 etype = rqlst.children[0].solutions[0]
   859                 basedescription.append(term.get_type(etype, args))
   864                 basedescription.append(term.get_type(etype, args))
   860         if not todetermine:
   865         if not todetermine:
   861             return [tuple(basedescription)] * len(result)
   866             return RepeatList(len(result), tuple(basedescription))
   862         return self._build_descr(result, basedescription, todetermine)
   867         return self._build_descr(result, basedescription, todetermine)
   863 
   868 
   864     def _build_descr(self, result, basedescription, todetermine):
   869     def _build_descr(self, result, basedescription, todetermine):
   865         description = []
   870         description = []
   866         etype_from_eid = self.describe
   871         etype_from_eid = self.describe