allura
修订版 | 8e0face292a005df91ea2f58c34c2d10f4e20d2f (tree) |
---|---|
时间 | 2012-06-27 23:34:48 |
作者 | Jenny Steele <jsteele@geek...> |
Commiter | Dave Brondsema |
[#4448] Removed neighborhood caching and instead started querying just the requested neighborhood
@@ -25,7 +25,6 @@ class CreateNeighborhoodCommand(base.Command): | ||
25 | 25 | google_analytics = False)) |
26 | 26 | project_reg = plugin.ProjectRegistrationProvider.get() |
27 | 27 | project_reg.register_neighborhood_project(n, admins) |
28 | - print "WARNING! You must restart the webserver before you can use the new neighborhood." | |
29 | 28 | |
30 | 29 | |
31 | 30 | class UpdateNeighborhoodCommand(base.Command): |
@@ -40,40 +40,34 @@ class W: | ||
40 | 40 | class RootController(WsgiDispatchController): |
41 | 41 | """ |
42 | 42 | The root controller for the allura application. |
43 | - | |
43 | + | |
44 | 44 | All the other controllers and WSGI applications should be mounted on this |
45 | 45 | controller. For example:: |
46 | - | |
46 | + | |
47 | 47 | panel = ControlPanelController() |
48 | 48 | another_app = AnotherWSGIApplication() |
49 | - | |
49 | + | |
50 | 50 | Keep in mind that WSGI applications shouldn't be mounted directly: They |
51 | 51 | must be wrapped around with :class:`tg.controllers.WSGIAppController`. |
52 | - | |
52 | + | |
53 | 53 | """ |
54 | - | |
54 | + | |
55 | 55 | auth = AuthController() |
56 | 56 | error = ErrorController() |
57 | 57 | nf = NewForgeController() |
58 | 58 | nf.admin = SiteAdminController() |
59 | 59 | search = SearchController() |
60 | 60 | rest = RestController() |
61 | - neighborhoods_bound = False | |
62 | 61 | |
63 | 62 | def __init__(self): |
64 | - if not self.neighborhoods_bound: | |
65 | - self.bind_controllers() | |
63 | + n_url_prefix = '/%s/' % request.path.split('/')[1] | |
64 | + n = M.Neighborhood.query.get(url_prefix=n_url_prefix) | |
65 | + if n and not n.url_prefix.startswith('//'): | |
66 | + n.bind_controller(self) | |
66 | 67 | self.browse = ProjectBrowseController() |
67 | 68 | self.allura_sitemap = SitemapIndexController() |
68 | 69 | super(RootController, self).__init__() |
69 | 70 | |
70 | - @classmethod | |
71 | - def bind_controllers(cls): | |
72 | - for n in M.Neighborhood.query.find(): | |
73 | - if n.url_prefix.startswith('//'): continue | |
74 | - n.bind_controller(cls) | |
75 | - cls.neighborhoods_bound = True | |
76 | - | |
77 | 71 | def _setup_request(self): |
78 | 72 | c.project = c.app = None |
79 | 73 | c.memoize_cache = {} |
@@ -41,6 +41,7 @@ class Neighborhood(MappedClass): | ||
41 | 41 | class __mongometa__: |
42 | 42 | session = main_orm_session |
43 | 43 | name = 'neighborhood' |
44 | + unique_indexes = [ 'url_prefix' ] | |
44 | 45 | |
45 | 46 | _id = FieldProperty(S.ObjectId) |
46 | 47 | name = FieldProperty(str) |