Skip to content

Instantly share code, notes, and snippets.

@iffy
Created September 21, 2011 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iffy/1232602 to your computer and use it in GitHub Desktop.
Save iffy/1232602 to your computer and use it in GitHub Desktop.
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