<s> from pymongo import collection <EOL> from pymongo import mongo_client <EOL> from pymongo import database <EOL> from pymongo import mongo_replica_set_client <EOL> from flask import abort <EOL> class MongoClient ( mongo_client . MongoClient ) : <EOL> """<STR_LIT>""" <EOL> def __getattr__ ( self , name ) : <EOL> attr = super ( MongoClient , self ) . __getattr__ ( name ) <EOL> if isinstance ( attr , database . Database ) : <EOL> return Database ( self , name ) <EOL> return attr <EOL> def __getitem__ ( self , item ) : <EOL> attr = super ( MongoClient , self ) . __getitem__ ( item ) <EOL> if isinstance ( attr , database . Database ) : <EOL> return Database ( self , item ) <EOL> return attr <EOL> class MongoReplicaSetClient ( mongo_replica_set_client . MongoReplicaSetClient ) : <EOL> """<STR_LIT>""" <EOL> def __getattr__ ( self , name ) : <EOL> attr = super ( MongoReplicaSetClient , self ) . __getattr__ ( name ) <EOL> if isinstance ( attr , database . Database ) : <EOL> return Database ( self , name ) <EOL> return attr <EOL> def __getitem__ ( self , item ) : <EOL> item_ = super ( MongoReplicaSetClient , self ) . __getitem__ ( item ) <EOL> if isinstance ( item_ , database . Database ) : <EOL> return Database ( self , item ) <EOL> return item_ <EOL> class Database ( database . Database ) : <EOL> """<STR_LIT>""" <EOL> def __getattr__ ( self , name ) : <EOL> attr = super ( Database , self ) . __getattr__ ( name ) <EOL> if isinstance ( attr , collection . Collection ) : <EOL> return Collection ( self , name ) <EOL> return attr <EOL> def __getitem__ ( self , item ) : <EOL> item_ = super ( Database , self ) . __getitem__ ( item ) <EOL> if isinstance ( item_ , collection . Collection ) : <EOL> return Collection ( self , item ) <EOL> return item_ <EOL> class Collection ( collection . Collection ) : <EOL> """<STR_LIT>""" <EOL> def __getattr__ ( self , name ) : <EOL> attr = super ( Collection , self ) . __getattr__ ( name ) <EOL> if isinstance ( attr , collection . Collection ) : <EOL> db = self . _Collection__database <EOL> return Collection ( db , attr . name ) <EOL> return attr <EOL> def __getitem__ ( self , item ) : <EOL> item_ = super ( Collection , self ) . __getitem__ ( item ) <EOL> if isinstance ( item_ , collection . Collection ) : <EOL> db = self . _Collection__database <EOL> return Collection ( db , item_ . name ) <EOL> return item_ <EOL> def find_one_or_404 ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> found = self . find_one ( * args , ** kwargs ) <EOL> if found is None : <EOL> abort ( <NUM_LIT> ) <EOL> return found </s>
