OLD | NEW |
1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 """The entrypoint for the pub.dartlang.org server. | 5 """The entrypoint for the pub.dartlang.org server. |
6 | 6 |
7 In development, this should be run using the App Engine dev_appserver.py script. | 7 In development, this should be run using the App Engine dev_appserver.py script. |
8 """ | 8 """ |
9 | 9 |
10 import json | 10 import json |
11 import logging | 11 import logging |
12 | 12 |
13 import cherrypy | 13 import cherrypy |
14 from google.appengine.api import users | 14 from google.appengine.api import users |
15 from google.appengine.ext.webapp.util import run_wsgi_app | 15 from google.appengine.ext.webapp.util import run_wsgi_app |
16 | 16 |
17 import handlers | 17 import handlers |
18 import handlers.api as api | 18 import handlers.api as api |
19 from handlers.doc import Doc | |
20 from handlers.root import Root | 19 from handlers.root import Root |
21 from handlers.packages import Packages | 20 from handlers.packages import Packages |
22 from handlers.package_uploaders import PackageUploaders | 21 from handlers.package_uploaders import PackageUploaders |
23 from handlers.package_versions import PackageVersions | 22 from handlers.package_versions import PackageVersions |
24 from handlers.private_keys import PrivateKeys | 23 from handlers.private_keys import PrivateKeys |
25 | 24 |
26 class Application(cherrypy.Application): | 25 class Application(cherrypy.Application): |
27 """The pub.dartlang.org WSGI application.""" | 26 """The pub.dartlang.org WSGI application.""" |
28 | 27 |
29 def __init__(self, *args, **kwargs): | 28 def __init__(self, *args, **kwargs): |
30 super(Application, self).__init__(None, *args, **kwargs) | 29 super(Application, self).__init__(None, *args, **kwargs) |
31 self.dispatcher = cherrypy.dispatch.RoutesDispatcher() | 30 self.dispatcher = cherrypy.dispatch.RoutesDispatcher() |
32 self.merge({'/': {'request.dispatch': self.dispatcher}}) | 31 self.merge({'/': {'request.dispatch': self.dispatcher}}) |
33 | 32 |
34 # Frontend routes (also deprecated v1 API routes) | 33 # Frontend routes (also deprecated v1 API routes) |
35 self.dispatcher.connect('root', '/', Root(), action='index') | 34 self.dispatcher.connect('root', '/', Root(), action='index') |
36 self.dispatcher.mapper.connect( | 35 self.dispatcher.mapper.connect( |
37 '/authorized', controller='root', action='authorized') | 36 '/authorized', controller='root', action='authorized') |
38 self.dispatcher.mapper.connect( | 37 self.dispatcher.mapper.connect( |
39 '/site-map', controller='root', action='site_map') | 38 '/site-map', controller='root', action='site_map') |
40 self.dispatcher.mapper.connect( | 39 self.dispatcher.mapper.connect( |
41 '/search', controller='root', action='search') | 40 '/search', controller='root', action='search') |
42 self.dispatcher.mapper.connect( | 41 self.dispatcher.mapper.connect( |
43 '/admin', controller='root', action='admin') | 42 '/admin', controller='root', action='admin') |
44 self.dispatcher.mapper.connect( | 43 self.dispatcher.mapper.connect( |
45 '/gs_/{filename:.*?}', controller='root', action='serve') | 44 '/gs_/{filename:.*?}', controller='root', action='serve') |
46 | 45 |
47 self.dispatcher.connect('doc', '/doc', Doc(), action='index') | |
48 self.dispatcher.connect( | |
49 'doc', '/doc/{filename:.*?}', Doc(), action='show') | |
50 | |
51 self._resource('package', 'packages', Packages()) | 46 self._resource('package', 'packages', Packages()) |
52 self._resource('private-key', 'private-keys', PrivateKeys()) | 47 self._resource('private-key', 'private-keys', PrivateKeys()) |
53 | 48 |
54 self._resource('version', 'versions', PackageVersions(), | 49 self._resource('version', 'versions', PackageVersions(), |
55 parent_resource={ | 50 parent_resource={ |
56 'member_name': 'package', | 51 'member_name': 'package', |
57 'collection_name': 'packages' | 52 'collection_name': 'packages' |
58 }, | 53 }, |
59 member={ | 54 member={ |
60 'create': 'GET', | 55 'create': 'GET', |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return str(handlers.render('error', | 150 return str(handlers.render('error', |
156 status=status, | 151 status=status, |
157 message=message, | 152 message=message, |
158 traceback=traceback, | 153 traceback=traceback, |
159 layout={'title': 'Error %s' % status})) | 154 layout={'title': 'Error %s' % status})) |
160 | 155 |
161 app = Application() | 156 app = Application() |
162 | 157 |
163 if __name__ == "__main__": | 158 if __name__ == "__main__": |
164 run_wsgi_app(app) | 159 run_wsgi_app(app) |
OLD | NEW |