コード例 #1
0
    def __init__(self, session, menu_items=None):
        if not (hasattr(self, 'table') or hasattr(self, 'table_type')):
            class Table(SortableTableBase):
                __entity__=self.model
            self.table = Table(session)

        if not (hasattr(self, 'table_filler') or hasattr(self, 'table_filler_type')):
            class MyTableFiller(RequestLocalTableFiller):
                __entity__ = self.model
            self.table_filler = MyTableFiller(session)

        if not (hasattr(self, 'edit_form') or hasattr(self, 'edit_form_type')):
            class EditForm(EditableForm):
                __entity__ = self.model
            self.edit_form = EditForm(session)

        if not (hasattr(self, 'edit_filler') or hasattr(self, 'edit_filler_type')):
            class EditFiller(RecordFiller):
                __entity__ = self.model
            self.edit_filler = EditFiller(session)

        if not (hasattr(self, 'new_form') or hasattr(self, 'new_form_type')):
            class NewForm(AddRecordForm):
                __entity__ = self.model
            self.new_form = NewForm(session)

        if not (hasattr(self, 'new_filler') or hasattr(self, 'new_filler_type')):
            class NewFiller(AddFormFiller):
                __entity__ = self.model
            self.new_filler = NewFiller(session)
        
        super(EasyCrudRestController, self).__init__(session, menu_items)

        #Permit to quickly customize form options
        if hasattr(self, '__form_options__'):
            for name, value in self.__form_options__.items():
                for form in (self.edit_form, self.new_form):
                    if form:
                        setattr(form, name, value)

        #Permit to quickly create custom actions to set values
        if hasattr(self, '__setters__'):
            for name, config in self.__setters__.items():
                setattr(self, name, create_setter(self, self.get_all, config))


        #Permit to quickly customize table options
        if hasattr(self, '__table_options__'):
            for name, value in self.__table_options__.items():
                if name.startswith('__') and name != '__actions__':
                    for table_object in (self.table_filler, self.table):
                        if table_object:
                            setattr(table_object, name, value)
                else:
                    if self.table_filler:
                        set_table_filler_getter(self.table_filler, name, value)
コード例 #2
0
    def __init__(self, session, menu_items=None):
        if not (hasattr(self, 'table') or hasattr(self, 'table_type')):

            class Table(SortableTableBase):
                __entity__ = self.model

            self.table = Table(session)

        if not (hasattr(self, 'table_filler')
                or hasattr(self, 'table_filler_type')):

            class MyTableFiller(RequestLocalTableFiller):
                __entity__ = self.model

            self.table_filler = MyTableFiller(session)

        if not (hasattr(self, 'edit_form') or hasattr(self, 'edit_form_type')):

            class EditForm(EditableForm):
                __entity__ = self.model

            self.edit_form = EditForm(session)

        if not (hasattr(self, 'edit_filler')
                or hasattr(self, 'edit_filler_type')):

            class EditFiller(RecordFiller):
                __entity__ = self.model

            self.edit_filler = EditFiller(session)

        if not (hasattr(self, 'new_form') or hasattr(self, 'new_form_type')):

            class NewForm(AddRecordForm):
                __entity__ = self.model

            self.new_form = NewForm(session)

        if not (hasattr(self, 'new_filler')
                or hasattr(self, 'new_filler_type')):

            class NewFiller(AddFormFiller):
                __entity__ = self.model

            self.new_filler = NewFiller(session)

        super(EasyCrudRestController, self).__init__(session, menu_items)

        #Permit to quickly customize form options
        if hasattr(self, '__form_options__'):
            for name, value in self.__form_options__.items():
                for form in (self.edit_form, self.new_form):
                    if form:
                        setattr(form, name, value)

        #Permit to quickly create custom actions to set values
        if hasattr(self, '__setters__'):
            for name, config in self.__setters__.items():
                setattr(self, name, create_setter(self, self.get_all, config))

        #Permit to quickly customize table options
        if hasattr(self, '__table_options__'):
            for name, value in self.__table_options__.items():
                if name.startswith('__') and name != '__actions__':
                    for table_object in (self.table_filler, self.table):
                        if table_object:
                            setattr(table_object, name, value)
                else:
                    if self.table_filler:
                        set_table_filler_getter(self.table_filler, name, value)
コード例 #3
0
ファイル: controller.py プロジェクト: TurboGears/tgext.crud
    def __init__(self, session, menu_items=None):
        if not (hasattr(self, 'table') or hasattr(self, 'table_type')):
            class Table(SortableTableBase):
                __entity__=self.model
            self.table = Table(session)

        if not (hasattr(self, 'table_filler') or hasattr(self, 'table_filler_type')):
            class MyTableFiller(RequestLocalTableFiller):
                __entity__ = self.model
            self.table_filler = MyTableFiller(session)

        if not (hasattr(self, 'edit_form') or hasattr(self, 'edit_form_type')):
            class EditForm(EditableForm):
                __entity__ = self.model
            self.edit_form = EditForm(session)

        if not (hasattr(self, 'edit_filler') or hasattr(self, 'edit_filler_type')):
            class EditFiller(RecordFiller):
                __entity__ = self.model
            self.edit_filler = EditFiller(session)

        if not (hasattr(self, 'new_form') or hasattr(self, 'new_form_type')):
            class NewForm(AddRecordForm):
                __entity__ = self.model
            self.new_form = NewForm(session)

        if not (hasattr(self, 'new_filler') or hasattr(self, 'new_filler_type')):
            class NewFiller(AddFormFiller):
                __entity__ = self.model
            self.new_filler = NewFiller(session)
        
        super(EasyCrudRestController, self).__init__(session, menu_items)

        # Permit to quickly customize form options
        if hasattr(self, '__form_options__'):
            for form in (self.edit_form, self.new_form):
                if form:
                    for name, value in self.__form_options__.items():
                        if isinstance(value, (_addoptsdict, _addoptslist)):
                            value.extend_option(form, name)
                        else:
                            setattr(form, name, value)

        if hasattr(self, '__form_new_options__') and self.new_form:
            for name, value in self.__form_new_options__.items():
                if isinstance(value, (_addoptsdict, _addoptslist)):
                    value.extend_option(self.new_form, name)
                else:
                    setattr(self.new_form, name, value)

        if hasattr(self, '__form_edit_options__') and self.edit_form:
            for name, value in self.__form_edit_options__.items():
                if isinstance(value, (_addoptsdict, _addoptslist)):
                    value.extend_option(self.edit_form, name)
                else:
                    setattr(self.edit_form, name, value)

        if hasattr(self, '__setters__'):
            raise ValueError('__setters__ are deprecated and no longer supported.')

        # Permit to quickly customize table options
        if hasattr(self, '__table_options__'):
            if self.table_filler:
                for name, value in self.__table_options__.items():
                    if name == '__actions__':
                        set_table_filler_getter(self.table_filler, name, value)
                    elif name.startswith('__'):
                        setattr(self.table_filler, name, value)
                    else:
                        set_table_filler_getter(self.table_filler, name, value)

            if self.table:
                for name, value in self.__table_options__.items():
                    if name.startswith('__') and name != '__actions__':
                        setattr(self.table, name, value)
コード例 #4
0
    def __init__(self, session, menu_items=None):
        if not (hasattr(self, 'table') or hasattr(self, 'table_type')):

            class Table(SortableTableBase):
                __entity__ = self.model

            self.table = Table(session)

        if not (hasattr(self, 'table_filler')
                or hasattr(self, 'table_filler_type')):

            class MyTableFiller(RequestLocalTableFiller):
                __entity__ = self.model

            self.table_filler = MyTableFiller(session)

        if not (hasattr(self, 'edit_form') or hasattr(self, 'edit_form_type')):

            class EditForm(EditableForm):
                __entity__ = self.model

            self.edit_form = EditForm(session)

        if not (hasattr(self, 'edit_filler')
                or hasattr(self, 'edit_filler_type')):

            class EditFiller(RecordFiller):
                __entity__ = self.model

            self.edit_filler = EditFiller(session)

        if not (hasattr(self, 'new_form') or hasattr(self, 'new_form_type')):

            class NewForm(AddRecordForm):
                __entity__ = self.model

            self.new_form = NewForm(session)

        if not (hasattr(self, 'new_filler')
                or hasattr(self, 'new_filler_type')):

            class NewFiller(AddFormFiller):
                __entity__ = self.model

            self.new_filler = NewFiller(session)

        super(EasyCrudRestController, self).__init__(session, menu_items)

        # Permit to quickly customize form options
        if hasattr(self, '__form_options__'):
            for form in (self.edit_form, self.new_form):
                if form:
                    for name, value in self.__form_options__.items():
                        if isinstance(value, (_addoptsdict, _addoptslist)):
                            value.extend_option(form, name)
                        else:
                            setattr(form, name, value)

        if hasattr(self, '__form_new_options__') and self.new_form:
            for name, value in self.__form_new_options__.items():
                if isinstance(value, (_addoptsdict, _addoptslist)):
                    value.extend_option(self.new_form, name)
                else:
                    setattr(self.new_form, name, value)

        if hasattr(self, '__form_edit_options__') and self.edit_form:
            for name, value in self.__form_edit_options__.items():
                if isinstance(value, (_addoptsdict, _addoptslist)):
                    value.extend_option(self.edit_form, name)
                else:
                    setattr(self.edit_form, name, value)

        if hasattr(self, '__setters__'):
            raise ValueError(
                '__setters__ are deprecated and no longer supported.')

        # Permit to quickly customize table options
        if hasattr(self, '__table_options__'):
            if self.table_filler:
                for name, value in self.__table_options__.items():
                    if name == '__actions__':
                        set_table_filler_getter(self.table_filler, name, value)
                    elif name.startswith('__'):
                        setattr(self.table_filler, name, value)
                    else:
                        set_table_filler_getter(self.table_filler, name, value)

            if self.table:
                for name, value in self.__table_options__.items():
                    if name.startswith('__') and name != '__actions__':
                        setattr(self.table, name, value)