<s> from . utils import has_rel_db , get_model_or_document <EOL> if has_rel_db ( ) : <EOL> from django . contrib . contenttypes . models import ContentType , ContentTypeManager <EOL> else : <EOL> from django . contrib . contenttypes . models import ContentTypeManager as DjangoContentTypeManager <EOL> from mongoengine . queryset import QuerySet <EOL> from mongoengine . django . auth import ContentType <EOL> from mongodbforms import init_document_options <EOL> from mongodbforms . documentoptions import patch_document <EOL> class ContentTypeManager ( DjangoContentTypeManager ) : <EOL> def get_query_set ( self ) : <EOL> """<STR_LIT>""" <EOL> return QuerySet ( self . model , self . model . _get_collection ( ) ) <EOL> def contribute_to_class ( self , model , name ) : <EOL> init_document_options ( model ) <EOL> super ( ContentTypeManager , self ) . contribute_to_class ( model , name ) <EOL> def get_object_for_this_type ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> return self . model_class ( ) . objects . get ( ** kwargs ) <EOL> def model_class ( self ) : <EOL> return get_model_or_document ( str ( self . app_label ) , str ( self . model ) ) <EOL> patch_document ( get_object_for_this_type , ContentType , bound = False ) <EOL> patch_document ( model_class , ContentType , bound = False ) <EOL> manager = ContentTypeManager ( ) <EOL> manager . contribute_to_class ( ContentType , '<STR_LIT>' ) <EOL> try : <EOL> from grappelli . templatetags import grp_tags <EOL> grp_tags . ContentType = ContentType <EOL> except ImportError : <EOL> pass </s>
