forked from ungleich-public/dynamicweb
clone cms with menus, make menus standalone app
This commit is contained in:
parent
1ece5ce7c7
commit
afb096b7a3
1153 changed files with 318897 additions and 37 deletions
31
cms/context_processors.py
Normal file
31
cms/context_processors.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
from functools import cache
|
||||
|
||||
from django.utils.functional import lazy
|
||||
|
||||
from cms.utils.conf import get_cms_setting
|
||||
from cms.utils.page import get_page_template_from_request
|
||||
|
||||
|
||||
def cms_settings(request):
|
||||
"""
|
||||
Adds cms-related variables to the context.
|
||||
"""
|
||||
from menus.menu_pool import MenuRenderer
|
||||
|
||||
@cache
|
||||
def _get_menu_renderer():
|
||||
# We use lru_cache to avoid getting the manager
|
||||
# every time this function is called.
|
||||
from menus.menu_pool import menu_pool
|
||||
return menu_pool.get_renderer(request)
|
||||
|
||||
# Now use lazy() to avoid getting the menu renderer
|
||||
# up until the point is needed.
|
||||
# lazy() does not memoize results, is why lru_cache is needed.
|
||||
_get_menu_renderer = lazy(_get_menu_renderer, MenuRenderer)
|
||||
|
||||
return {
|
||||
'cms_menu_renderer': _get_menu_renderer(),
|
||||
'CMS_MEDIA_URL': get_cms_setting('MEDIA_URL'),
|
||||
'CMS_TEMPLATE': lambda: get_page_template_from_request(request),
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue