#!/usr/bin/env python # vim: set filencoding=utf8 """ Foundry Main Application @author: Mike Crute (mcrute@gmail.com) @organization: SoftGroup Interactive, Inc. @date: May 02, 2010 Entry point for the application. All of the main app wireup happens here. This is also where you can get the WSGI application object. This isn't strictly required. You could wire this all up by hand. """ import jinja2 from snakeguice import Injector from snakeguice.extras.snakeweb import Application, AutoRoutesModule from foundry.utils import frozendict from foundry import controllers, interfaces from foundry.views import JinjaRenderer from foundry.template_filters import TEMPLATE_FILTERS from foundry.vcs.hg.providers import RepoProvider class MainModule(object): def configure(self, binder): #------------------------------------------------------------- # Mercurial Bindings #------------------------------------------------------------- binder.bind(interfaces.RepositoryProvider, to=RepoProvider) #------------------------------------------------------------- # Template Engine Bindings #------------------------------------------------------------- loader = jinja2.PackageLoader('foundry', 'views') tpl_env = jinja2.Environment(loader=loader) tpl_env.filters.update(TEMPLATE_FILTERS) renderer = JinjaRenderer(tpl_env) binder.bind(interfaces.TemplateRenderer, to_instance=renderer) class MapperModule(AutoRoutesModule): configured_routes = frozendict({ '/': controllers.ChangelogController, }) def get_application(): injector = Injector([MainModule(), MapperModule()]) return Application(injector) if __name__ == '__main__': from wsgiref.simple_server import make_server httpd = make_server('', 8080, get_application()) httpd.serve_forever()