def repopulate_app_cache(self): """ Rebuilds AppCache with the real model definitions. """ if DJANGO_17: apps.clear_cache() else: cache._populate()
def repopulate_app_cache(self): """ Rebuilds AppCache with the real model definitions. """ if DJANGO_17: apps.clear_cache() else: cache._populate()
def unclear_app_cache(self): """ Reversed the effects of clear_app_cache. """ if DJANGO_17: apps.all_models = self.old_app_models apps.clear_cache() else: cache.app_models = self.old_app_models cache._get_models_cache = {}
def unclear_app_cache(self): """ Reversed the effects of clear_app_cache. """ if DJANGO_17: apps.all_models = self.old_app_models apps.clear_cache() else: cache.app_models = self.old_app_models cache._get_models_cache = {}
def clear_app_cache(): """Clear the Django app/models caches. This cache is used in Django >= 1.2 to quickly return results when fetching models. It needs to be cleared when modifying the model registry. """ if apps: # Django >= 1.7 apps.clear_cache() elif hasattr(cache, '_get_models_cache'): # Django >= 1.2, < 1.7 cache._get_models_cache.clear()
def clear_app_cache(): """Clear the Django app/models caches. This cache is used in Django >= 1.2 to quickly return results when fetching models. It needs to be cleared when modifying the model registry. """ if apps: # Django >= 1.7 apps.clear_cache() elif hasattr(cache, '_get_models_cache'): # Django >= 1.2, < 1.7 cache._get_models_cache.clear()
def clear_app_cache(self): """ Clears the contents of AppCache to a blank state, so new models from the ORM can be added. """ # Django 1.7+ throws a runtime error in some situations due to model validation: # >>> RuntimeError: Conflicting 'user' models in application 'sentry': <class 'sentry.models.user.User'> and <class 'sentry.models.User'>. if DJANGO_17: self.old_app_models, apps.all_models = apps.all_models, defaultdict(OrderedDict) apps.clear_cache() else: self.old_app_models, cache.app_models = cache.app_models, {}
def clear_app_cache(self): """ Clears the contents of AppCache to a blank state, so new models from the ORM can be added. """ # Django 1.7+ throws a runtime error in some situations due to model validation: # >>> RuntimeError: Conflicting 'user' models in application 'sentry': <class 'sentry.models.user.User'> and <class 'sentry.models.User'>. if DJANGO_17: self.old_app_models, apps.all_models = apps.all_models, defaultdict(OrderedDict) apps.clear_cache() else: self.old_app_models, cache.app_models = cache.app_models, {}
def make_all(config=None, force=False): """ Make all models from config file """ if not settings.SKIP_FLEX_MODELS or force: flex_model_list = [] if config is None: config = get_db_config(force) thismodule = sys.modules[__name__] # iterating over all defined models for model_name, model_meta in config.iteritems(): model = make_flex_model(model_name, model_meta) flex_model_list.append(model_name) setattr(thismodule, model_name, model) apps.clear_cache() setattr(thismodule, 'flex_model_list', flex_model_list)
def make_all(config=None, force=False): """ Make all models from config file """ if not settings.SKIP_FLEX_MODELS or force: flex_model_list = [] if config is None: config = get_db_config(force) thismodule = sys.modules[__name__] # iterating over all defined models for model_name, model_meta in config.iteritems(): model = make_flex_model(model_name, model_meta) flex_model_list.append(model_name) setattr(thismodule, model_name, model) apps.clear_cache() setattr(thismodule, 'flex_model_list', flex_model_list)
def tearDown(self): apps.app_configs['contenttypes_tests'].models = self._old_models apps.all_models['contenttypes_tests'] = self._old_models apps.clear_cache()
def tearDown(self): apps.app_configs['contenttypes_tests'].models = self._old_models apps.all_models['contenttypes_tests'] = self._old_models apps.clear_cache()