Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ladok_lib/ladok3.nw
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}).
<<LadokSession data methods>>=
@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 = []
<<filter students by attributes>>
return students
@


\subsection{Courses}

Expand Down