#NEWLINE# def __getitem__( self , key ) : #NEWLINE# #INDENT# if isinstance ( key , User ) : #NEWLINE# #INDENT# key = key . id #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( key , str ) : #NEWLINE# #INDENT# orm_user = self . db . query ( orm . User ) . filter ( ( orm . User . name == key ) ) . first ( ) #NEWLINE# if ( orm_user is None ) : #NEWLINE# #INDENT# raise KeyError ( ( 'No such user: %s' % key ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# key = orm_user #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if isinstance ( key , orm . User ) : #NEWLINE# #INDENT# orm_user = key #NEWLINE# if ( orm_user . id not in self ) : #NEWLINE# #INDENT# user = self [ orm_user . id ] = User ( orm_user , self . settings ) #NEWLINE# return user #NEWLINE# #UNINDENT# user = dict . __getitem__ ( self , orm_user . id ) #NEWLINE# user . db = self . db #NEWLINE# return user #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( key , int ) : #NEWLINE# #INDENT# id = key #NEWLINE# if ( id not in self ) : #NEWLINE# #INDENT# orm_user = self . db . query ( orm . User ) . filter ( ( orm . User . id == id ) ) . first ( ) #NEWLINE# if ( orm_user is None ) : #NEWLINE# #INDENT# raise KeyError ( ( 'No such user: %s' % id ) ) #NEWLINE# #UNINDENT# user = self [ id ] = User ( orm_user , self . settings ) #NEWLINE# #UNINDENT# return dict . __getitem__ ( self , id ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise KeyError ( repr ( key ) )