Beispiel #1
0
 def classPupils(self, klass, date=None):
     """Read the pupil data for the given school-class (possibly with
     streams).
     Return an ordered list of <PupilData> named tuples.
     If a <date> is supplied, pupils who left the school before that
     date will not be included.
     <klass> is a <Klass> instance. If it has no streams, all pupils
     are returned. If there are strems, only those pupils in one of
     the given streams are returned.
     To enable indexing on pupil-id, the result has an extra
     attribute, <pidmap>: {pid-> <PupilData> instance}
     """
     fetched = self.db.select('PUPILS', CLASS=klass.klass)
     rows = UserList()
     rows.pidmap = {}
     slist = klass.streams
     for row in fetched:
         pdata = PupilData(row)
         # Check exit date
         if date:
             exd = pdata['EXIT_D']
             if exd and exd < date:
                 continue
         # Check stream
         if (not slist) or ((pdata['STREAM'] or '_') in slist):
             rows.append(pdata)
             rows.pidmap[pdata['PID']] = pdata
     return rows