#NEWLINE# def dereference( self , dbref ) : #NEWLINE# #INDENT# if ( ( not dbref . collection ) or ( not dbref . id ) ) : #NEWLINE# #INDENT# raise TypeError ( ( 'cannot dereference a %s' % type ( dbref ) ) ) #NEWLINE# #UNINDENT# if ( ( dbref . database is not None ) and ( dbref . database != self . name ) ) : #NEWLINE# #INDENT# raise ValueError ( ( 'trying to dereference a DBRef that points to another database (%r not %r)' % ( dbref . database , dbref . __name ) ) ) #NEWLINE# #UNINDENT# return self [ dbref . collection ] . find_one ( { #NEWLINE# #INDENT# '_id' : dbref . id , #NEWLINE# #UNINDENT# } )