1. Alexander Solovyov
  2. svarga

Commits

Alexander Solovyov  committed 509aa0c

fix multiple calls for db configuration

  • Participants
  • Parent commits 6b7b0ef
  • Branches default

Comments (0)

Files changed (8)

File samples/simple/admin/manage.py

File contents unchanged.

File samples/simple/bundle/manage.py

File contents unchanged.

File samples/simple/customauth/manage.py

File contents unchanged.

File samples/simple/modelformset/manage.py

File contents unchanged.

File samples/simple/multiapp/manage.py

File contents unchanged.

File svarga/core/conf/local_settings.py

View file
 LOCAL_INIT = [
     'svarga.apps.LocalSettingsProvider',
     'svarga.template.LocalSettingsProvider',
-    'svarga.core.database.database_local_init',
     ]
 
 # Application initializers
 APPS_INIT = [
     'svarga.template.apps.contribute',
+    'svarga.core.database.database_init',
     ]
 
 # Enabled template loaders

File svarga/core/database.py

View file
             else:
                 return opts, {}
 
-        if self.databases:
-            return
-
         self.databases = {}
         databases = databases.copy()
 
 db = Database()
 
 
-def database_configuration(appsettings):
-    db.configure(getattr(appsettings.env_class.settings, 'DATABASES', {}))
-AppSettings._initializers.append(database_configuration)
+def models_autoimport(apps, env_class):
+    for app in apps:
+        import_module(app + '.models', required=False)
 
-def database_local_init(env_class):
+
+def database_init(app_settings, env_class):
     env_class.middlewares.insert(0, autocommit)
-    for app in env_class.apps:
-        import_module(app + '.models', required=False)
+    db.configure(getattr(env_class.settings, 'DATABASES', {}))
+    return models_autoimport

File svarga/template/apps.py

View file
 
 from svarga.utils.imports import import_module
 
-def app_config_manager(apps, env_class):
+def templating_autoimport(apps, env_class):
     '''Application configuration manager for templates.
     '''
+    # just import to register template filters etc
     for app, config in apps.iteritems():
-        app_templating = app + '.templating'
-
-        # just import to register template filters etc
-        import_module(app_templating, required=False)
+        import_module(app + '.templating', required=False)
 
 def contribute(app_settings, env_class):
     def add_template_path(self, prefix, path):
     app_settings.add_template_path = add_template_path
     app_settings._templates = {}
 
-    return app_config_manager
+    return templating_autoimport