def query_for_course(course_key, category=None):
 if getattr(course_key, 'deprecated', False):
  prefix = '_id'
 else:
  prefix = 'content_son'
 dbkey = SON([('{}.tag'.format(prefix), XASSET_LOCATION_TAG), ('{}.org'.format(prefix), course_key.org), ('{}.course'.format(prefix), course_key.course)])
 if category:
  dbkey['{}.category'.format(prefix)] = category
 if getattr(course_key, 'deprecated', False):
  dbkey['{}.run'.format(prefix)] = {'$exists': False}
 else:
  dbkey['{}.run'.format(prefix)] = course_key.run
 return dbkey

def query_for_course ( course_key , category = None ) : if getattr ( course_key , 'deprecated' , False ) : prefix = '_id' else : prefix = 'content_son' dbkey = SON ( [ ( '{}.tag' . format ( prefix ) , XASSET_LOCATION_TAG ) , ( '{}.org' . format ( prefix ) , course_key . org ) , ( '{}.course' . format ( prefix ) , course_key . course ) ] ) if category : dbkey [ '{}.category' . format ( prefix ) ] = category if getattr ( course_key , 'deprecated' , False ) : dbkey [ '{}.run' . format ( prefix ) ] = { '$exists' : False } else : dbkey [ '{}.run' . format ( prefix ) ] = course_key . run return dbkey
construct a son object that will query for all assets possibly limited to the given type in the course using the index in mongo_indexes .