Beispiel #1
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 = self.provider_type_selector_type().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))

        # Register forms that need to be validated for each action.
        if hasattr(self, 'new_form'):
            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 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 #3
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 #4
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)