diff options
author | tilly-Q <nattilypigeonfowl@gmail.com> | 2013-07-31 20:49:07 -0400 |
---|---|---|
committer | tilly-Q <nattilypigeonfowl@gmail.com> | 2013-07-31 20:49:07 -0400 |
commit | 07e61ef13a62752d1321f2e9b6e6ff62d474023c (patch) | |
tree | d12ee72a2368d68174b81a4c147f4c22f60d9f36 /mediagoblin/gmg_commands/dbupdate.py | |
parent | a1e299d60e135905e39358fe5dc1efcd64172daf (diff) | |
parent | 860fa806ee3af0260b9f8f6f02dd606fb55678f5 (diff) | |
download | mediagoblin-07e61ef13a62752d1321f2e9b6e6ff62d474023c.tar.lz mediagoblin-07e61ef13a62752d1321f2e9b6e6ff62d474023c.tar.xz mediagoblin-07e61ef13a62752d1321f2e9b6e6ff62d474023c.zip |
Merge branch 'ticket-679' of gitorious.org:~npigeon/mediagoblin/npigeons-mediagoblin
Diffstat (limited to 'mediagoblin/gmg_commands/dbupdate.py')
-rw-r--r-- | mediagoblin/gmg_commands/dbupdate.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/mediagoblin/gmg_commands/dbupdate.py b/mediagoblin/gmg_commands/dbupdate.py index 00007567..bad3e352 100644 --- a/mediagoblin/gmg_commands/dbupdate.py +++ b/mediagoblin/gmg_commands/dbupdate.py @@ -32,14 +32,15 @@ def dbupdate_parse_setup(subparser): class DatabaseData(object): - def __init__(self, name, models, migrations): + def __init__(self, name, models, foundations, migrations): self.name = name self.models = models + self.foundations = foundations self.migrations = migrations def make_migration_manager(self, session): return MigrationManager( - self.name, self.models, self.migrations, session) + self.name, self.models, self.foundations, self.migrations, session) def gather_database_data(plugins): @@ -54,10 +55,11 @@ def gather_database_data(plugins): # Add main first from mediagoblin.db.models import MODELS as MAIN_MODELS from mediagoblin.db.migrations import MIGRATIONS as MAIN_MIGRATIONS + from mediagoblin.db.models import FOUNDATIONS as MAIN_FOUNDATIONS managed_dbdata.append( DatabaseData( - u'__main__', MAIN_MODELS, MAIN_MIGRATIONS)) + u'__main__', MAIN_MODELS, MAIN_FOUNDATIONS, MAIN_MIGRATIONS)) for plugin in plugins: try: @@ -83,13 +85,26 @@ forgotten to add it? ({1})'.format(plugin, exc)) migrations = {} except AttributeError as exc: - _log.debug('Cloud not find MIGRATIONS in {0}.migrations, have you \ + _log.debug('Could not find MIGRATIONS in {0}.migrations, have you \ forgotten to add it? ({1})'.format(plugin, exc)) migrations = {} + try: + foundations = import_component('{0}.models:FOUNDATIONS'.format(plugin)) + except ImportError as exc: + _log.debug('No foundations found for {0}: {1}'.format( + plugin, + exc)) + + foundations = [] + except AttributeError as exc: + _log.debug('Could not find FOUNDATIONS in {0}.models, have you \ +forgotten to add it? ({1})'.format(plugin, exc)) + foundations = {} + if models: managed_dbdata.append( - DatabaseData(plugin, models, migrations)) + DatabaseData(plugin, models, foundations, migrations)) return managed_dbdata |