#NEWLINE# def __getattr__( self , name ) : #NEWLINE# #INDENT# '\n        Returns the attribute from the _document if it exists.\n        Returns it from the collection if not on _document, but on collection.\n        ' #NEWLINE# if ( name in self . _document ) : #NEWLINE# #INDENT# return self . _document [ name ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name in dir ( self . collection ) ) : #NEWLINE# #INDENT# attribute = getattr ( self . collection , name ) #NEWLINE# if inspect . isfunction ( attribute ) : #NEWLINE# #INDENT# attribute = types . MethodType ( attribute , self ) #NEWLINE# #UNINDENT# return attribute #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise AttributeError ( name )