From 8c3b386e0176fd255f3637ea9da28d9712f078b0 Mon Sep 17 00:00:00 2001 From: idle sign Date: Thu, 30 Jul 2015 19:40:44 +0600 Subject: [PATCH] Fixed cache problems when using sitetree_resync_apps (see #135, #166). --- CHANGELOG | 1 + .../commands/sitetree_resync_apps.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8f36f02e..9438c210 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ Unreleased + Added Norwegian translation. + Added SITETREE_RAISE_ITEMS_ERRORS_ON_DEBUG setting (see #157). + Exposed SITETREE_CACHE_TIMEOUT setting. +* Fixed cache problems when using sitetree_resync_apps (see #135, #166). v1.4.0 diff --git a/sitetree/management/commands/sitetree_resync_apps.py b/sitetree/management/commands/sitetree_resync_apps.py index bfda7689..b389b322 100644 --- a/sitetree/management/commands/sitetree_resync_apps.py +++ b/sitetree/management/commands/sitetree_resync_apps.py @@ -5,6 +5,7 @@ from sitetree.utils import get_tree_model, import_project_sitetree_modules from sitetree.settings import APP_MODULE_NAME +from sitetree.sitetreeapp import Cache MODEL_TREE_CLASS = get_tree_model() @@ -12,12 +13,17 @@ class Command(BaseCommand): - help = 'Places sitetrees of the project applications (defined in `app_name.sitetree.py`) into DB, replacing old ones if any.' + help = 'Places sitetrees of the project applications (defined in `app_name.sitetree.py`) into DB, ' \ + 'replacing old ones if any.' + args = '[app_name app_name ...]' + option_list = BaseCommand.option_list + ( - make_option('--database', action='store', dest='database', - default=DEFAULT_DB_ALIAS, help='Nominates a specific database to place trees and items into. Defaults to the "default" database.'), - ) + make_option( + '--database', action='store', dest='database', default=DEFAULT_DB_ALIAS, + help='Nominates a specific database to place trees and items into. Defaults to the "default" database.' + ), + ) def handle(self, *apps, **options): using = options.get('database', DEFAULT_DB_ALIAS) @@ -30,7 +36,7 @@ def handle(self, *apps, **options): for module in tree_modules: sitetrees = getattr(module, 'sitetrees', None) app = module.__dict__['__package__'] - if not apps or (apps and app in apps): + if not apps or app in apps: if sitetrees is not None: self.stdout.write('Sitetrees found in `%s` app ...\n' % app) for tree in sitetrees: @@ -52,3 +58,5 @@ def handle(self, *apps, **options): # Copy permissions to M2M field once `item` # has been saved item.access_permissions = item.permissions + + Cache.reset()