#NEWLINE# def install_migrations( self , loader ) : #NEWLINE# #INDENT# 'Python dumps are generated with one line near the end of their\n    `restore.py` file which calls this method, passing it their global\n    namespace::\n\n      settings.SITE.install_migrations(globals())\n\n    A dumped fixture should always call this, even if there is no\n    version change and no data migration, because this also does\n    certain other things:\n\n    - set :setting:`loading_from_dump` to `True`\n    - remove any Permission and Site objects that might have been\n      generated by `post_syncdb` signal if these apps are installed.\n\n    ' #NEWLINE# globals_dict = loader . globals_dict #NEWLINE# self . loading_from_dump = True #NEWLINE# if self . is_installed ( 'auth' ) : #NEWLINE# #INDENT# from django.contrib.auth.models import Permission #NEWLINE# Permission . objects . all ( ) . delete ( ) #NEWLINE# #UNINDENT# if self . is_installed ( 'sites' ) : #NEWLINE# #INDENT# from django.contrib.sites.models import Site #NEWLINE# Site . objects . all ( ) . delete ( ) #NEWLINE# #UNINDENT# current_version = self . version #NEWLINE# if ( current_version is None ) : #NEWLINE# #INDENT# logger . info ( 'Unversioned Site instance : no database migration' ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( globals_dict [ 'SOURCE_VERSION' ] == mc ) : #NEWLINE# #INDENT# logger . info ( 'Source version is %s : no migration needed' , current_version ) #NEWLINE# return #NEWLINE# #UNINDENT# if ( self . migration_class is not None ) : #NEWLINE# #INDENT# mc = import_string ( self . migration_class ) #NEWLINE# migrator = mc ( self , loader ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# migrator = self #NEWLINE# #UNINDENT# while True : #NEWLINE# #INDENT# from_version = globals_dict [ 'SOURCE_VERSION' ] #NEWLINE# funcname = ( 'migrate_from_' + from_version . replace ( '.' , '_' ) ) #NEWLINE# m = getattr ( migrator , funcname , None ) #NEWLINE# if ( m is not None ) : #NEWLINE# #INDENT# to_version = m ( globals_dict ) #NEWLINE# if ( not isinstance ( to_version , basestring ) ) : #NEWLINE# #INDENT# raise Exception ( ( "Oops, %s didn't return a string!" % m ) ) #NEWLINE# #UNINDENT# if ( to_version <= from_version ) : #NEWLINE# #INDENT# raise Exception ( ( 'Oops, %s tries to migrate from version %s to %s ?!' % ( m , from_version , to_version ) ) ) #NEWLINE# #UNINDENT# msg = ( 'Migrating from version %s to %s' % ( from_version , to_version ) ) #NEWLINE# if m . __doc__ : #NEWLINE# #INDENT# msg += ( ':\n' + m . __doc__ ) #NEWLINE# #UNINDENT# logger . info ( msg ) #NEWLINE# globals_dict [ 'SOURCE_VERSION' ] = to_version #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( from_version != current_version ) : #NEWLINE# #INDENT# logger . warning ( 'No method for migrating from version %s to %s' , from_version , current_version ) #NEWLINE# #UNINDENT# break