#NEWLINE# def get_leaf_queryset( parent_klass , index , filter = 'pk' ) : #NEWLINE# #INDENT# "\n    Same as L{get_queryset} but also calls the C{as_leaf_class} function\n    on the first element in the queryset and returns a queryset with the\n    returned object's class.\n    " #NEWLINE# def wrapper( * args , **kwargs ) : #NEWLINE# #INDENT# if ( type ( index ) == int ) : #NEWLINE# #INDENT# arg = args [ index ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# arg = kwargs [ index ] #NEWLINE# #UNINDENT# parent_qs = parent_klass . objects . filter ( ** { #NEWLINE# #INDENT# filter : arg , #NEWLINE# #UNINDENT# } ) #NEWLINE# parents = list ( parent_qs ) #NEWLINE# if parents : #NEWLINE# #INDENT# ids = [ p . id for p in parents ] #NEWLINE# return parents [ 0 ] . as_leaf_class ( ) . __class__ . objects . filter ( id__in = ids ) #NEWLINE# #UNINDENT# return parent_qs #NEWLINE# #UNINDENT# return index