Пример #1
0
    def __init__(self, *args, **kwargs):
        """
        :param name: Unique name for identifying the column.
        :type name: str
        :param entity: The Entity object that the column belongs to.
        :type entity: Entity
        **Keyword arguments:**
        - *description:* Text providing more information about the column.
        - *Mandatory:* True if the column requires a value to be supplied
        when entering data. Default is False.
        - *Searchable:* True if the column can be used to filter records in
        the Entity browser. Default is True but is dependent on the subclass
        implementation.
        - *unique:* True to include a UNIQUE constraint for the column.
        - *user_tip:* Hint that will appear in the form editor as a tooltip
        for this column.
         - *index:* True to indicate that the column should be indexed.
         - *label:* Text to appear as the column label in the form editor.
        """
        if len(args) < 2:
            raise Exception('Constructor requires name and entity arguments.')

        name = args[0]
        entity = args[1]

        ColumnItem.__init__(self, name)

        # Internal flag used to check whether this constructor has been initialized
        self._intialized = True

        # Attributes in the database that need to monitored for any changes
        self._monitor_attrs = ['mandatory', 'searchable', 'index', 'unique']

        self.updated_db_attrs = {}

        self.entity = entity
        self.profile = entity.profile
        self.description = kwargs.get('description', '')
        self.index = kwargs.get('index', False)
        self.mandatory = kwargs.get('mandatory', False)
        self.searchable = kwargs.get('searchable', True)
        self.unique = kwargs.get('unique', False)
        self.user_tip = kwargs.get('user_tip', '')
        self.label = kwargs.get('label', '')

        self.row_index = kwargs.get('row_index', -1)

        self.reset_updated_attrs()

        LOGGER.debug('%s column initialized in %s entity.', self.name,
                     self.entity.name)
Пример #2
0
    def __init__(self, *args, **kwargs):
        """
        :param name: Unique name for identifying the column.
        :type name: str
        :param entity: The Entity object that the column belongs to.
        :type entity: Entity
        **Keyword arguments:**
        - *description:* Text providing more information about the column.
        - *Mandatory:* True if the column requires a value to be supplied
        when entering data. Default is False.
        - *Searchable:* True if the column can be used to filter records in
        the Entity browser. Default is True but is dependent on the subclass
        implementation.
        - *unique:* True to include a UNIQUE constraint for the column.
        - *user_tip:* Hint that will appear in the form editor as a tooltip
        for this column.
         - *index:* True to indicate that the column should be indexed.
         - *label:* Text to appear as the column label in the form editor.
        """
        if len(args) < 2:
            raise Exception('Constructor requires name and entity arguments.')

        name = args[0]
        entity = args[1]

        ColumnItem.__init__(self, name)

        # Internal flag used to check whether this constructor has been initialized
        self._intialized = True

        # Attributes in the database that need to monitored for any changes
        self._monitor_attrs = ['mandatory', 'searchable', 'index', 'unique' ]

        self.updated_db_attrs = {}

        self.entity = entity
        self.profile = entity.profile
        self.description = kwargs.get('description', '')
        self.index = kwargs.get('index', False)
        self.mandatory = kwargs.get('mandatory', False)
        self.searchable = kwargs.get('searchable', True)
        self.unique = kwargs.get('unique', False)
        self.user_tip = kwargs.get('user_tip', '')
        self.label = kwargs.get('label', '')

        self.row_index = kwargs.get('row_index',-1)

        self.reset_updated_attrs()


        LOGGER.debug('%s column initialized in %s entity.',self.name, self.entity.name)