Skip to content

Commit

Permalink
Fixed cache problems when using sitetree_resync_apps (see #135, #166).
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign committed Jul 30, 2015
1 parent b27b1d6 commit 8c3b386
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions sitetree/management/commands/sitetree_resync_apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@

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()


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)
Expand All @@ -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:
Expand All @@ -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()

0 comments on commit 8c3b386

Please sign in to comment.