server/querier.py
changeset 9469 032825bbacab
parent 9467 ad66d7b3fd48
child 9508 1263f1258796
equal deleted inserted replaced
9468:39b7a91a3f4c 9469:032825bbacab
    69     node)
    69     node)
    70     """
    70     """
    71     try:
    71     try:
    72         return solution[term.name]
    72         return solution[term.name]
    73     except AttributeError:
    73     except AttributeError:
    74         return session.describe(term.eval(args))[0]
    74         return session.entity_metas(term.eval(args))['type']
    75 
    75 
    76 def check_read_access(session, rqlst, solution, args):
    76 def check_read_access(session, rqlst, solution, args):
    77     """Check that the given user has credentials to access data read by the
    77     """Check that the given user has credentials to access data read by the
    78     query and return a dict defining necessary "local checks" (i.e. rql
    78     query and return a dict defining necessary "local checks" (i.e. rql
    79     expression in read permission defined in the schema) where no group grants
    79     expression in read permission defined in the schema) where no group grants
   665         return RepeatList(len(result), tuple(basedescr))
   665         return RepeatList(len(result), tuple(basedescr))
   666     return _build_descr(tx, result, basedescr, todetermine)
   666     return _build_descr(tx, result, basedescr, todetermine)
   667 
   667 
   668 def _build_descr(tx, result, basedescription, todetermine):
   668 def _build_descr(tx, result, basedescription, todetermine):
   669     description = []
   669     description = []
   670     etype_from_eid = tx.describe
   670     entity_metas = tx.entity_metas
   671     todel = []
   671     todel = []
   672     for i, row in enumerate(result):
   672     for i, row in enumerate(result):
   673         row_descr = basedescription[:]
   673         row_descr = basedescription[:]
   674         for index, isfinal in todetermine:
   674         for index, isfinal in todetermine:
   675             value = row[index]
   675             value = row[index]
   679                 continue
   679                 continue
   680             if isfinal:
   680             if isfinal:
   681                 row_descr[index] = etype_from_pyobj(value)
   681                 row_descr[index] = etype_from_pyobj(value)
   682             else:
   682             else:
   683                 try:
   683                 try:
   684                     row_descr[index] = etype_from_eid(value)[0]
   684                     row_descr[index] = entity_metas(value)['type']
   685                 except UnknownEid:
   685                 except UnknownEid:
   686                     tx.error('wrong eid %s in repository, you should '
   686                     tx.error('wrong eid %s in repository, you should '
   687                              'db-check the database' % value)
   687                              'db-check the database' % value)
   688                     todel.append(i)
   688                     todel.append(i)
   689                     break
   689                     break