--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -29,6 +29,7 @@
import ew as ew_core
import ew.jinja2_ew as ew
+from ming.utils import LazyProperty
import allura.tasks.event_tasks
from allura import model as M
@@ -99,9 +100,6 @@
# Setup analytics
self.analytics = analytics.GoogleAnalytics(account=config.get('ga.account', 'UA-32013-57'))
-
- # Setup theme
- self.theme = plugin.ThemeProvider.get()
self.icons = dict(
admin = Icon('x', 'ico-admin'),
@@ -137,11 +135,28 @@
perm_admin = Icon('(', 'ico-lock'),
)
- self.tool_entry_points = dict(
- (ep.name, ep.load()) for ep in pkg_resources.iter_entry_points('allura'))
+ # Cache some loaded entry points
+ self.entry_points = dict(
+ tool=self._cache_eps('allura'),
+ auth=self._cache_eps('allura.auth'),
+ registration=self._cache_eps('allura.project_registration'),
+ theme=self._cache_eps('allura.theme'),
+ user_prefs=self._cache_eps('allura.user_prefs'),
+ )
+
+ def _cache_eps(self, section_name):
+ d = {}
+ for ep in pkg_resources.iter_entry_points(section_name):
+ value = ep.load()
+ d[ep.name] = d[ep.name.lower()] = value
+ return d
def post_event(self, topic, *args, **kwargs):
allura.tasks.event_tasks.event.post(topic, *args, **kwargs)
+
+ @LazyProperty
+ def theme(self):
+ return plugin.ThemeProvider.get()
@property
def antispam(self):