Beispiel #1
0
    def __init__(self, session, menu_items=None):
        if menu_items is None:
            menu_items = {}
        self.menu_items = menu_items
        self.provider = ProviderTypeSelector().get_selector(self.model).get_provider(self.model, hint=session)

        self.session = session

        #this makes crc declarative
        check_types = ['new_form', 'edit_form', 'table', 'table_filler', 'edit_filler']
        for type_ in check_types:
            if not hasattr(self, type_) and hasattr(self, type_+'_type'):
                setattr(self, type_, getattr(self, type_+'_type')(self.session))

        if hasattr(self, 'new_form'):
            #register the validators since they are none from the parent class
            register_validators(self, 'post', self.new_form)
        if hasattr(self, 'edit_form'):
            register_validators(self, 'put', self.edit_form)
Beispiel #2
0
    def __init__(self, session, menu_items=None):
        if hasattr(self, 'style'):
            warnings.warn(
                'style attribute is not supported anymore, '
                'resources attribute replaces it',
                DeprecationWarning,
                stacklevel=2)
            self.resources = (crud_script,
                              CSSSource(location='headbottom', src=self.style))

        if menu_items is None:
            menu_items = {}

        self.menu_items = self._adapt_menu_items(menu_items)
        self.helpers = CrudRestControllerHelpers()
        self.provider = ProviderTypeSelector().get_selector(
            self.model).get_provider(self.model, hint=session)
        self.session = session

        if self.json_dictify is True:
            self.json_dictify = {}

        #this makes crc declarative
        check_types = [
            'new_form', 'edit_form', 'table', 'table_filler', 'edit_filler'
        ]
        for type_ in check_types:
            if not hasattr(self, type_) and hasattr(self, type_ + '_type'):
                setattr(self, type_,
                        getattr(self, type_ + '_type')(self.session))

        # Enable pagination only if table_filler has support for request local __count__
        self.pagination_enabled = (self.pagination and isinstance(
            self.table_filler, RequestLocalTableFiller))

        if hasattr(self, 'new_form'):
            #register the validators since they are none from the parent class
            register_validators(self, 'post', self.new_form)
        if hasattr(self, 'edit_form'):
            register_validators(self, 'put', self.edit_form)
Beispiel #3
0
                __entity__ = self.model

            self.new_filler_type = NewFiller

    def __init__(self, model, translations=None, **kw):
        super(CrudRestControllerConfig, self).__init__()

        self.model = model
        self._do_init_with_translations(translations)
        self._post_init()

    def _do_init_with_translations(self, translations):
        pass


provider_type_selector = ProviderTypeSelector()


class AdminConfig(object):
    """
    :class attributes:

        **layout**
            The look and feel of the admin.
            Three builtin layouts are available: ``tgext.admin.layouts.BasicAdminLayout``,
            ``tgext.admin.layouts.BootstrapAdminLayout`` and
            ``tgext.admin.layouts.GroupedBootstrapAdminLayout``.

            .. note::
                ``GroupedBootstrapAdminLayout`` only works with the Genshi and Kajiki
                template languages, so it cannot be used when quickstarting with Jinja or Mako.
Beispiel #4
0
 def setup(self):
     self.type_selector = ProviderTypeSelector()