Beispiel #1
0
def load_template_source(template_name, template_dirs=None):
    """Loads templates from enabled extensions."""
    if manager:
        resource = "templates/" + template_name

        for extmgr in get_extension_managers():
            for ext in extmgr.get_enabled_extensions():
                package = ext.info.app_name

                try:
                    return (manager.resource_string(package, resource),
                            'extension:%s:%s ' % (package, resource))
                except Exception, e:
                    pass
Beispiel #2
0
    def _check_expired(self):
        """Checks each ExtensionManager for expired extension state.

        When the list of extensions on an ExtensionManager changes, or when
        the configuration of an extension changes, any other threads/processes
        holding onto extensions and configuration will go stale. This function
        will check each of those to see if they need to re-load their
        state.

        This is meant to be called before every HTTP request.
        """
        for extension_manager in get_extension_managers():
            if extension_manager.is_expired():
                extension_manager.load(full_reload=True)
Beispiel #3
0
def load_template_source(template_name, template_dirs=None):
    """Loads templates from enabled extensions."""
    if manager:
        resource = "templates/" + template_name

        for extmgr in get_extension_managers():
            for ext in extmgr.get_enabled_extensions():
                package = ext.info.app_name

                try:
                    return (manager.resource_string(package, resource),
                            'extension:%s:%s ' % (package, resource))
                except Exception:
                    pass

    raise TemplateDoesNotExist, template_name
Beispiel #4
0
    def get_extension_class(self):
        """Retrieves the python object for the extensions class."""
        try:
            # Import the function here to avoid a mutual
            # dependency.
            from djblets.extensions.base import get_extension_managers
        except:
            return None

        managers = get_extension_managers()
        for manager in managers:
            try:
                extension = manager.get_installed_extension(self.class_name)
                return extension
            except InvalidExtensionError:
                continue

        return None