server/session.py
branchstable
changeset 7969 d43569aaf5d6
parent 7815 2a164a9cf81c
child 7970 83075d897943
equal deleted inserted replaced
7966:63bead921966 7969:d43569aaf5d6
    58     """return a description for a result set"""
    58     """return a description for a result set"""
    59     description = []
    59     description = []
    60     for term in selected:
    60     for term in selected:
    61         description.append(term.get_type(solution, args))
    61         description.append(term.get_type(solution, args))
    62     return description
    62     return description
       
    63 
       
    64 def selection_idx_type(i, rqlst, args):
       
    65     """try to return type of term at index `i` of the rqlst's selection"""
       
    66     for select in rqlst.children:
       
    67         term = select.selection[i]
       
    68         for solution in select.solutions:
       
    69             try:
       
    70                 ttype = term.get_type(solution, args)
       
    71                 if ttype is not None:
       
    72                     return ttype
       
    73             except CoercionError:
       
    74                 return None
    63 
    75 
    64 @objectify_selector
    76 @objectify_selector
    65 def is_user_session(cls, req, **kwargs):
    77 def is_user_session(cls, req, **kwargs):
    66     """repository side only selector returning 1 if the session is a regular
    78     """repository side only selector returning 1 if the session is a regular
    67     user session and not an internal session
    79     user session and not an internal session
  1154         # not so easy, looks for variable which changes from one solution
  1166         # not so easy, looks for variable which changes from one solution
  1155         # to another
  1167         # to another
  1156         unstables = rqlst.get_variable_indices()
  1168         unstables = rqlst.get_variable_indices()
  1157         basedescr = []
  1169         basedescr = []
  1158         todetermine = []
  1170         todetermine = []
  1159         sampleselect = rqlst.children[0]
  1171         for i in xrange(len(rqlst.children[0].selection)):
  1160         samplesols = sampleselect.solutions[0]
  1172             ttype = selection_idx_type(i, rqlst, args)
  1161         for i, term in enumerate(sampleselect.selection):
  1173             if ttype is None or ttype == 'Any':
  1162             try:
       
  1163                 ttype = term.get_type(samplesols, args)
       
  1164             except CoercionError:
       
  1165                 ttype = None
  1174                 ttype = None
  1166                 isfinal = True
  1175                 isfinal = True
  1167             else:
  1176             else:
  1168                 if ttype is None or ttype == 'Any':
  1177                 isfinal = ttype in BASE_TYPES
  1169                     ttype = None
       
  1170                     isfinal = True
       
  1171                 else:
       
  1172                     isfinal = ttype in BASE_TYPES
       
  1173             if ttype is None or i in unstables:
  1178             if ttype is None or i in unstables:
  1174                 basedescr.append(None)
  1179                 basedescr.append(None)
  1175                 todetermine.append( (i, isfinal) )
  1180                 todetermine.append( (i, isfinal) )
  1176             else:
  1181             else:
  1177                 basedescr.append(ttype)
  1182                 basedescr.append(ttype)