diff --git a/ladok_lib/ladok3.nw b/ladok_lib/ladok3.nw index 4c4c18b..622a061 100644 --- a/ladok_lib/ladok3.nw +++ b/ladok_lib/ladok3.nw @@ -638,6 +638,26 @@ def get_student(self, id): return Student(ladok=self, id=id) @ +Sometimes we might want to search for a students using other attributes. +The [[kwargs]] dictionary contains keys that match the attributes of +[[Student]] objects. +The function will then return all students that match on all attributes +(conjunction\footnote{% + We can achieve a disjunction by calling [[find_student]] several times and + merge the results. +}). +<>= +@cachetools.cachedmethod( + operator.attrgetter("cache"), + key=functools.partial(cachetools.keys.hashkey, "find_student")) +def find_student(self, /, **kwargs): + """Search for a student by non-unique Student attributes, + returns a list of Student objects""" + students = [] + <> + return students +@ + \subsection{Courses}