def application(environ, start_response): local.request = request = Request(environ) settings = AppSettings() m = rxc.match(request.url) m = m.groupdict() if not any([m["host"].endswith(h) for h in settings.hosts]): redir = "%s%s%s" % (m["protocol"], settings.hosts[0], m["query"]) return redirect(redir) response = None layout_const("app_settings", jinja_const("app_settings", settings)) for nut in settings.nuts: ns = getattr(__import__("hazel.nuts.%s" % nut, fromlist=["hazel.nuts"]), "NutSettings", None) if ns: ns = ns() layout_const("%s_settings" % nut, ns) jinja_const("%s_settings" % nut, ns) local.adapter = adapter = local.url_map.bind_to_environ(environ) try: try: local.endpoint, local.args = endpoint, args = adapter.match() except RequestRedirect, e: return e return local.views[endpoint](request, **args)
def setup(): jinja_const('articles_settings', NutSettings())
from hazel.urls import build_urls from hazel.loader import LayoutLoader from hazel import jinja_env from hazel import layout_env from hazel import NutSettings as AppSettings ################################################################################ # globals ################################################################################ rx = "(?P<protocol>https?://)(?P<host>[^:/]+):?(?P<post>[^/]*)(?P<query>.*)" rxc = re.compile(rx) __app__ = jinja_const("app", "Hazel CMS") __version__ = jinja_const("version", "0.1") __author__ = jinja_const("author", "Moritz Angermann <*****@*****.**>") __copyright__ = jinja_const("copyright", "Copyright (c) 2008-2009, Moritz Angermann") __license__ = jinja_const("license", "BSD License") __URL__ = jinja_const("url", "http://www.hazel-cms.com") jinja_const("ct2fe", content_type_to_file_ext) jinja_const("fe2ct", file_ext_to_content_type) jinja_const("google_users", users) ################################################################################ # application ################################################################################ @debugged @manager.middleware @responder