# -*- coding: utf-8 -*- """Mako template options which are used, basically, by all handler modules in controllers of the app. """ from web.contrib.template import render_mako from settings import (absolute, DEBUG) # Mako Template options render = render_mako(directories=[absolute('app/views')], module_directory=absolute('tmp/mako_modules'), cache_dir=absolute('tmp/mako_cache'), input_encoding='utf-8', output_encoding='utf-8', default_filters=['decode.utf8'], encoding_errors='replace', filesystem_checks=DEBUG, collection_size=512)
global APP return APP # store = web.session.DBStore(db, 'sessions') # session = web.session.Session(get_app(), store, initializer={'loggedin': False}) # SESSION = web.session.Session(get_app(), store, initializer={'loggedin': False}) def get_session(): global SESSION return SESSION # Jinja2 Template options render = render_jinja(absolute('app/views'), encoding='utf-8') render._lookup.globals.update(ses=get_session(), ourDistricts=ourDistricts) def put_session(session): global SESSION SESSION = session render._lookup.globals.update(ses=session) def csrf_token(): session = get_session() if 'csrf_token' not in session: from uuid import uuid4 session.csrf_token = uuid4().hex
# -*- coding: utf-8 -*- """Mako template options which are used, basically, by all handler modules in controllers of the app. """ from web.contrib.template import render_mako from settings import (absolute, DEBUG) # Mako Template options render = render_mako( directories=[absolute('app/views')], module_directory=absolute('tmp/mako_modules'), cache_dir=absolute('tmp/mako_cache'), input_encoding='utf-8', output_encoding='utf-8', default_filters=['decode.utf8'], encoding_errors='replace', filesystem_checks=DEBUG, collection_size=512 )
return facilityLevels[facilityid] def getDistrict(districtid): return allDistricts[districtid] myFilters = { 'datetimeformat': datetimeformat, 'facilityLevel': facilityLevel, 'getDistrict': getDistrict, } # Jinja2 Template options render = render_jinja( absolute('app/views'), encoding='utf-8' ) render._lookup.globals.update( ses=get_session(), roles=roles, year=datetime.datetime.now().strftime('%Y'), ourDistricts=ourDistricts ) render._lookup.filters.update(myFilters) def put_session(session): global SESSION SESSION = session
from django.conf.urls.defaults import * from django.conf import settings from settings import absolute from django.contrib import admin # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('', # Example: # (r'^lanmpd/', include('lanmpd.foo.urls')), (r'^web/$', 'lanmpd.web.views.index'), (r'^web/login/$', 'django.contrib.auth.views.login', {'template_name': absolute('templates/auth.html')}), (r'^web/logout/$', 'lanmpd.web.views.unauth'), (r'^web/player/$', 'lanmpd.web.views.player'), (r'^web/player/change_song/$', 'lanmpd.web.views.change_song'), # Uncomment the admin/doc line below and add 'django.contrib.admindocs' # to INSTALLED_APPS to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/$', include(admin.site.urls)) ) if settings.DEVELOPMENT: urlpatterns += patterns('', (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}))