<s> from . db_settings import get_model_indexes <EOL> from . stubs import stub_manager <EOL> from djangotoolbox . db . creation import NonrelDatabaseCreation <EOL> class StringType ( object ) : <EOL> def __init__ ( self , internal_type ) : <EOL> self . internal_type = internal_type <EOL> def __mod__ ( self , field ) : <EOL> indexes = get_model_indexes ( field [ '<STR_LIT>' ] ) <EOL> if field [ '<STR_LIT:name>' ] in indexes [ '<STR_LIT>' ] : <EOL> return '<STR_LIT:text>' <EOL> elif field [ '<STR_LIT:name>' ] in indexes [ '<STR_LIT>' ] : <EOL> return '<STR_LIT>' <EOL> return self . internal_type <EOL> def get_data_types ( ) : <EOL> string_types = ( '<STR_LIT:text>' , '<STR_LIT>' ) <EOL> data_types = NonrelDatabaseCreation . data_types . copy ( ) <EOL> for name , field_type in data_types . items ( ) : <EOL> if field_type in string_types : <EOL> data_types [ name ] = StringType ( field_type ) <EOL> return data_types <EOL> class DatabaseCreation ( NonrelDatabaseCreation ) : <EOL> data_types = get_data_types ( ) <EOL> def _create_test_db ( self , * args , ** kw ) : <EOL> self . _had_test_stubs = stub_manager . active_stubs != '<STR_LIT:test>' <EOL> if self . _had_test_stubs : <EOL> stub_manager . activate_test_stubs ( ) <EOL> def _destroy_test_db ( self , * args , ** kw ) : <EOL> if self . _had_test_stubs : <EOL> stub_manager . deactivate_test_stubs ( ) <EOL> stub_manager . setup_stubs ( self . connection ) <EOL> del self . _had_test_stubs </s>
