Skip to content
This repository has been archived by the owner on Dec 22, 2022. It is now read-only.

Commit

Permalink
Verion 0.6b4: Added a setting for the cache prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Oct 15, 2013
1 parent 8afaac0 commit 92acaa1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion navbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'minor': 6,
'micro': 0,
'releaselevel': 'beta',
'serial': 3
'serial': 4
}


Expand Down
10 changes: 5 additions & 5 deletions navbar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.utils.translation import ugettext_lazy as _
from categories.base import CategoryBase

from navbar.settings import STORAGE_CLASS, UPLOAD_TO
from navbar.settings import STORAGE_CLASS, UPLOAD_TO, CACHE_PREFIX

USER_TYPE_CHOICES = [
('E', _('Everybody')),
Expand Down Expand Up @@ -75,11 +75,11 @@ def __unicode__(self):
return self.name

def save(self):
cache.delete('site_navtree')
cache.delete('site_navtree_super')
cache.delete('%s_site_navtree' % CACHE_PREFIX)
cache.delete('%s_site_navtree_super' % CACHE_PREFIX)
return super(NavBarEntry, self).save()

def delete(self, *args, **kwdargs):
cache.delete('site_navtree')
cache.delete('site_navtree_super')
cache.delete('%s_site_navtree' % CACHE_PREFIX)
cache.delete('%s_site_navtree_super' % CACHE_PREFIX)
return super(NavBarEntry, self).delete(*args, **kwdargs)
1 change: 1 addition & 0 deletions navbar/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
'CRUMBS_STRIP_ROOT': True,
'CRUMBS_HOME': 'home',
'ROOT_URL': '/',
'CACHE_PREFIX': ''
}

USER_SETTINGS = DEFAULT_SETTINGS.copy()
Expand Down
7 changes: 5 additions & 2 deletions navbar/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .settings import CACHE_PREFIX


def _Qperm(user=None):
from django.db.models.query import Q
exQ = Q()
Expand Down Expand Up @@ -48,11 +51,11 @@ def navlevel(base, invdepth, parent=None):

def get_navtree(user=None, maxdepth=-1):
from django.core.cache import cache
cachename = 'site_navtree'
cachename = '%s_site_navtree' % CACHE_PREFIX
timeout = 60 * 60 * 24
if user is not None and not user.is_anonymous():
if user.is_superuser:
cachename = 'site_navtree_super'
cachename = '%s_site_navtree_super' % CACHE_PREFIX
else:
cachename = 'site_navtree_' + str(user.id)
timeout = 60 * 15
Expand Down

0 comments on commit 92acaa1

Please sign in to comment.