X-Git-Url: https://git.sommitrealweird.co.uk/sommitrealweird.git/blobdiff_plain/7b250882b48932b7fc6a68575273c3fcbfcef97f..refs/heads/django-4.2:/sommitrealweird/bpcms/context_processors.py?ds=sidebyside diff --git a/sommitrealweird/bpcms/context_processors.py b/sommitrealweird/bpcms/context_processors.py index 72c335d..1d254b1 100644 --- a/sommitrealweird/bpcms/context_processors.py +++ b/sommitrealweird/bpcms/context_processors.py @@ -33,7 +33,7 @@ def content_menu(request): pass menu_items.sort( \ - cmp=lambda x,y: cmp(x['title'].lower(), y['title'].lower())) + key=lambda x: x['title'].lower()) cache.set('bpcms_mainmenu', menu_items, 3600) return { @@ -44,9 +44,16 @@ def content_submenu(request): # find where we are in the tree first folderpath = request.path folderpath = re.sub(u'^%s' %(settings.BPCMS_ROOT), '', folderpath) + # right - that should be any prefix got rid of, now traverse the tree till # we've got something - menu_items = cache.get('bpcms_contentmenu_%s' %(folderpath)) + try: + menu_items = cache.get('bpcms_contentmenu_%s' %(folderpath)) + except: + # fail on cache engine or bad key, ignore + return { + 'content_submenu': {}, + } if not menu_items: folder = None @@ -87,7 +94,7 @@ def content_submenu(request): ) menu_items.sort( \ - cmp=lambda x,y: cmp(x['title'].lower(), y['title'].lower())) + key=lambda x: x['title'].lower()) cache.set('bpcms_contentmenu_%s' %("/".join(folderpath)), menu_items)