-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
111 lines (86 loc) · 3.57 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Course Builder web application entry point."""
__author__ = 'Pavel Simakov ([email protected])'
import os
import webapp2
# The following import is needed in order to add third-party libraries.
import appengine_config # pylint: disable-msg=unused-import
from common import tags
from controllers import sites
from models import custom_modules
from modules.activity_tag import activity_tag
from modules.admin import admin
from modules.announcements import announcements
from modules.assessment_tags import questions
from modules.course_explorer import course_explorer
from modules.courses import courses
from modules.dashboard import dashboard
from modules.mapreduce import mapreduce_module
from modules.oauth2 import oauth2
from modules.oeditor import oeditor
from modules.review import review
from modules.search import search
from modules.upload import upload
# from modules.FAQ import FAQ
# use this flag to control debug only features
debug = not appengine_config.PRODUCTION_MODE
# init and enable most known modules
# FAQ.register_module().enable()
activity_tag.register_module().enable()
admin.register_module().enable()
announcements.register_module().enable()
questions.register_module().enable()
course_explorer.register_module().enable()
courses.register_module().enable()
dashboard.register_module().enable()
mapreduce_module.register_module().enable()
oeditor.register_module().enable()
review.register_module().enable()
search.register_module().enable()
upload.register_module().enable()
# I added customized FAQ module
#print FAQ.register_module()
# print FAQ.register_module().namespaced_routes
# print courses.register_module().namespaced_routes
# register modules that are not enabled by default.
oauth2.register_module()
# compute all possible routes
# print "All the registered routes"
# print custom_modules.Registry.get_all_routes()
global_routes, namespaced_routes = custom_modules.Registry.get_all_routes()
# routes available at '/%namespace%/' context paths
sites.ApplicationRequestHandler.bind(namespaced_routes)
app_routes = [(r'(.*)', sites.ApplicationRequestHandler)]
# enable Appstats handlers if requested
appstats_routes = []
if appengine_config.gcb_appstats_enabled():
# pylint: disable-msg=g-import-not-at-top
import google.appengine.ext.appstats.ui as appstats_ui
# pylint: enable-msg=g-import-not-at-top
# add all Appstats URL's to /admin/stats basepath
for path, handler in appstats_ui.URLMAP:
assert '.*' == path[:2]
appstats_routes.append(('/admin/stats/%s' % path[3:], handler))
# tag extension resource routes
extensions_routes = [(
'/extensions/tags/.*/resources/.*', tags.ResourcesHandler)]
# i18n configuration for jinja2
webapp2_i18n_config = {'translations_path': os.path.join(
appengine_config.BUNDLE_ROOT, 'modules/i18n/resources/locale')}
# init application
app = webapp2.WSGIApplication(
global_routes + extensions_routes + appstats_routes + app_routes,
config={'webapp2_extras.i18n': webapp2_i18n_config},
debug=debug)