<s> from django . db import models <EOL> from dockit . schema . loading import get_base_document <EOL> import datetime <EOL> from decimal import Decimal <EOL> from dockit . backends . djangodocument . managers import BaseIndexManager , DocumentManager , RegisteredIndexManager <EOL> class DocumentStore ( models . Model ) : <EOL> collection = models . CharField ( max_length = <NUM_LIT> ) <EOL> data = models . TextField ( ) <EOL> objects = DocumentManager ( ) <EOL> def clear_indexes ( self ) : <EOL> for index in type ( self ) . objects . index_models . itervalues ( ) : <EOL> index [ '<STR_LIT>' ] . objects . clear_db_index ( self ) <EOL> class RegisteredIndex ( models . Model ) : <EOL> name = models . CharField ( max_length = <NUM_LIT> , db_index = True ) <EOL> collection = models . CharField ( max_length = <NUM_LIT> , db_index = True ) <EOL> query_hash = models . CharField ( max_length = <NUM_LIT> ) <EOL> objects = RegisteredIndexManager ( ) <EOL> def get_document ( self ) : <EOL> return get_base_document ( self . collection ) <EOL> class Meta : <EOL> unique_together = [ ( '<STR_LIT:name>' , '<STR_LIT>' ) ] <EOL> class RegisteredIndexDocument ( models . Model ) : <EOL> index = models . ForeignKey ( RegisteredIndex , related_name = '<STR_LIT>' ) <EOL> doc_id = models . CharField ( max_length = <NUM_LIT> , db_index = True ) <EOL> data = models . TextField ( blank = True ) <EOL> timestamp = models . DateTimeField ( auto_now = True ) <EOL> class BaseIndex ( models . Model ) : <EOL> document = models . ForeignKey ( RegisteredIndexDocument ) <EOL> param_name = models . CharField ( max_length = <NUM_LIT> , db_index = True ) <EOL> objects = BaseIndexManager ( ) <EOL> class Meta : <EOL> abstract = True <EOL> class IntegerIndex ( BaseIndex ) : <EOL> value = models . IntegerField ( null = True ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT:int>' , IntegerIndex , int ) <EOL> class LongIndex ( BaseIndex ) : <EOL> value = models . BigIntegerField ( null = True ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT>' , LongIndex , long ) <EOL> class BooleanIndex ( BaseIndex ) : <EOL> value = models . NullBooleanField ( ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT:bool>' , BooleanIndex , bool ) <EOL> class StringIndex ( BaseIndex ) : <EOL> value = models . CharField ( max_length = <NUM_LIT> , null = True ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT>' , StringIndex , ( basestring , type ( None ) ) ) <EOL> class TextIndex ( BaseIndex ) : <EOL> value = models . TextField ( null = True ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT:text>' , TextIndex , basestring ) <EOL> class DateTimeIndex ( BaseIndex ) : <EOL> value = models . DateTimeField ( null = True ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT>' , DateTimeIndex , datetime . datetime ) <EOL> class DateIndex ( BaseIndex ) : <EOL> value = models . DateField ( null = True ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT:date>' , DateIndex , datetime . date ) <EOL> class FloatIndex ( BaseIndex ) : <EOL> value = models . FloatField ( null = True ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT:float>' , FloatIndex , float ) <EOL> class TimeIndex ( BaseIndex ) : <EOL> value = models . TimeField ( null = True ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT:time>' , TimeIndex , datetime . time ) <EOL> class DecimalIndex ( BaseIndex ) : <EOL> value = models . DecimalField ( max_digits = <NUM_LIT> , decimal_places = <NUM_LIT:10> , null = True ) <EOL> RegisteredIndex . objects . register_index_model ( '<STR_LIT>' , DecimalIndex , Decimal ) </s>
