Created
September 21, 2011 16:42
-
-
Save iffy/1232602 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getRecords(kw=None): | |
""" | |
@param kw: A dictionary of narrowing criteria for the records. For example, | |
if you wanted to only show records for student's named "Bill" you would | |
pass:: | |
{'first': 'Bill'} | |
""" | |
if not kw: | |
kw = {} | |
records = store.find((Student, Class, Grade), | |
Student.id == Grade.student_id, | |
Grade.class_id == Class.id) | |
if 'student_id' in kw: | |
records = records.find(Student.id == unicode(kw['student_id'])) | |
if 'class_id' in kw: | |
records = records.find(Class.id == int(kw['class_id'])) | |
if 'first' in kw: | |
records = records.find(Student.first == unicode(kw['first'])) | |
#... | |
return records |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment