Opened 10 years ago
#752 new defect
Refactoring notifications to more cleanly hook into application
|Reported by:||Christopher Allan Webber||Owned by:|
Right now, notifications' tooling are kind of "special case"'ed into the application. See especially:
template_env.globals = hook_transform( 'template_global_context', template_env.globals) #### THIS IS TEMPORARY, PLEASE FIX IT ## Notifications stuff is not yet a plugin (and we're not sure it will be), ## but it needs to add stuff to the context. This is THE WRONG WAY TO DO IT from mediagoblin import notifications template_env.globals['get_notifications'] = notifications.get_notifications template_env.globals[ 'get_notification_count'] = notifications.get_notification_count template_env.globals[ 'get_comment_subscription'] = notifications.get_comment_subscription if exists(locale): SETUP_JINJA_ENVS[locale] = template_env return template_env
This isn't nice... as far as I can tell, there's no reson for notifications to not be a plugin though? That would fix the issue of hardcoding these utilities into the template context.
Alternately maybe if there are some plugins that are so core they should always be on and might as well be core, but it's cleaner to use the template machinery, maybe we could provide a way to have a "always loaded" set of "plugins"... even though they're soldered into the outlet ;)