Beispiel #1
0
def showPage(request, suffix):
    """ Return a processed static page from the CMS. suffix should match the URL 
field in the URLs table."""
    setCMSContext(request)
    try:
        urlObject = URL.objects.get(enabled = True, url = "/%s"%suffix)
        doc =  returnComponent(request, urlObject.component_name)
    except Exception, ex:
        print ex
        doc = ""
Beispiel #2
0
def returnComponent(request, component_name):
    """ Return a processed component. Request can have language and channel GET 
arguments to override the defaults."""
    setCMSContext(request)
    # apply any context overides requested
    setContext(request)
    try:
        response = renderComponentDirect(
                getElementWithContext(CMSComponent, cid=component_name)
                )
    except Exception, ex:
        print ex
        response = ""
Beispiel #3
0
def setContext(request):
    """Set the channel/language CMS context into the session. This a means by which
the channel/language can be set. Use the GET arguments as follows::
    
    channel : channel name
    language : language name
    redirect : page to which to redirect (default to /)

Should either language or channel be missing it is pulled from the existing 
context object in the session.

Should invalid arguments be passed this method fails silently. 
"""
    currentContext = request.session['ZCMS_CONTEXT']
    channel = request.GET.get('channel', currentContext.channel.name)
    language = request.GET.get('language', currentContext.language.iso_code)
    site = request.GET.get('site', currentContext.site)
    redirect = request.GET.get('redirect', '/')
    try:
        context = CMSContext(language_iso = language, channel = channel, site=site)
        setCMSContext(request, context)
    except Exception, ex:
        pass