Exemplo n.º 1
0
    def __init__(self, models, session, config_type=None, translations=None):
        super(AdminController, self).__init__()
        if translations is None:
            translations = {}
        if config_type is None:
            config = AdminConfig(models, translations)
        else:
            config = config_type(models, translations)

        if config.allow_only is not None:
            self.allow_only = config.allow_only

        self.config = config
        self.session = session
        self.missing_template = False

        if self.config.default_index_template:
            expose(self.config.default_index_template)(self.index)
        else:
            if milestones is None:
                self._choose_index_template()
            else:
                milestones.renderers_ready.register(
                    self._choose_index_template)

        self.controllers_cache = {}
Exemplo n.º 2
0
    def __init__(self, models, session, config_type=None, translations=None):
        super(AdminController, self).__init__()
        if translations is None:
            translations = {}
        if config_type is None:
            config = AdminConfig(models, translations)
        else:
            config = config_type(models, translations)

        if config.allow_only:
            self.allow_only = config.allow_only

        self.config = config
        self.session = session
        self.missing_template = False

        if self.config.default_index_template:
            expose(self.config.default_index_template)(self.index)
        else:
            if milestones is None:
                self._choose_index_template()
            else:
                milestones.renderers_ready.register(self._choose_index_template)

        self.controllers_cache = {}
Exemplo n.º 3
0
    def _choose_index_template(self):
        default_renderer = self._get_default_renderer()
        if not default_renderer:
            return

        index_template = ':'.join((default_renderer, self.config.layout.template_index))
        expose(index_template)(self.index)
Exemplo n.º 4
0
    def _choose_index_template(self):
        default_renderer = self._get_default_renderer()
        if not default_renderer:
            self.missing_template = True
            return

        index_template = ':'.join(
            (default_renderer, self.config.layout.template_index))
        expose(index_template)(self.index)
Exemplo n.º 5
0
    def _choose_index_template(self):
        default_renderer = getattr(tg_config, 'default_renderer', 'genshi')
        if default_renderer not in ['genshi', 'mako', 'jinja']:
            if 'genshi' in tg_config.renderers:
                default_renderer = 'genshi'
            elif 'mako' in tg_config.renderers:
                default_renderer = 'mako'
            elif 'jinja' in tg_config.renderers:
                default_renderer = 'jinja'
            else:
                log.warn('TurboGears admin supports only Genshi, Mako and Jinja, please make sure you add at \
least one of those to your config/app_cfg.py base_config.renderers list.')
                self.missing_template = True

        index_template = ':'.join((default_renderer, self.config.layout.template_index))
        expose(index_template)(self.index)
Exemplo n.º 6
0
    def _choose_index_template(self):
        default_renderer = getattr(tg_config, 'default_renderer', 'genshi')
        if default_renderer not in ['genshi', 'mako', 'jinja']:
            if 'genshi' in tg_config.renderers:
                default_renderer = 'genshi'
            elif 'mako' in tg_config.renderers:
                default_renderer = 'mako'
            elif 'jinja' in tg_config.renderers:
                default_renderer = 'jinja'
            else:
                log.warn(
                    'TurboGears admin supports only Genshi, Mako and Jinja, please make sure you add at \
least one of those to your config/app_cfg.py base_config.renderers list.')
                self.missing_template = True

        index_template = ':'.join(
            (default_renderer, self.config.layout.template_index))
        expose(index_template)(self.index)