diff options
Diffstat (limited to 'foundry/application.py')
-rw-r--r-- | foundry/application.py | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/foundry/application.py b/foundry/application.py new file mode 100644 index 0000000..bc4a569 --- /dev/null +++ b/foundry/application.py | |||
@@ -0,0 +1,63 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # vim: set filencoding=utf8 | ||
3 | """ | ||
4 | Foundry Main Application | ||
5 | |||
6 | @author: Mike Crute (mcrute@gmail.com) | ||
7 | @organization: SoftGroup Interactive, Inc. | ||
8 | @date: May 02, 2010 | ||
9 | |||
10 | Entry point for the application. All of the main app | ||
11 | wireup happens here. This is also where you can get | ||
12 | the WSGI application object. This isn't strictly | ||
13 | required. You could wire this all up by hand. | ||
14 | """ | ||
15 | |||
16 | import jinja2 | ||
17 | from snakeguice import Injector | ||
18 | from snakeguice.extras.snakeweb import Application, AutoRoutesModule | ||
19 | |||
20 | from foundry.utils import frozendict | ||
21 | from foundry import controllers, interfaces | ||
22 | from foundry.views import JinjaRenderer | ||
23 | from foundry.template_filters import TEMPLATE_FILTERS | ||
24 | |||
25 | from foundry.vcs.hg.providers import RepoProvider | ||
26 | |||
27 | |||
28 | class MainModule(object): | ||
29 | |||
30 | def configure(self, binder): | ||
31 | #------------------------------------------------------------- | ||
32 | # Mercurial Bindings | ||
33 | #------------------------------------------------------------- | ||
34 | binder.bind(interfaces.RepositoryProvider, to=RepoProvider) | ||
35 | |||
36 | #------------------------------------------------------------- | ||
37 | # Template Engine Bindings | ||
38 | #------------------------------------------------------------- | ||
39 | loader = jinja2.PackageLoader('foundry', 'views') | ||
40 | tpl_env = jinja2.Environment(loader=loader) | ||
41 | tpl_env.filters.update(TEMPLATE_FILTERS) | ||
42 | renderer = JinjaRenderer(tpl_env) | ||
43 | |||
44 | binder.bind(interfaces.TemplateRenderer, to_instance=renderer) | ||
45 | |||
46 | |||
47 | class MapperModule(AutoRoutesModule): | ||
48 | |||
49 | configured_routes = frozendict({ | ||
50 | '/': controllers.ChangelogController, | ||
51 | }) | ||
52 | |||
53 | |||
54 | def get_application(): | ||
55 | injector = Injector([MainModule(), MapperModule()]) | ||
56 | return Application(injector) | ||
57 | |||
58 | |||
59 | if __name__ == '__main__': | ||
60 | from wsgiref.simple_server import make_server | ||
61 | |||
62 | httpd = make_server('', 8080, get_application()) | ||
63 | httpd.serve_forever() | ||