示例#1
0
    def __init__(self, *args, **kwargs):
        max_length = kwargs.pop('size', 20)

        if 'type_' in kwargs:
            del kwargs['type_']

        self.sqlalchemy_type = ColorType(max_length)
        super(Color, self).__init__(*args, **kwargs)
示例#2
0
class Color(Column):
    """Color column.
    `See coulour pakage <https://pypi.python.org/pypi/colour/>`_

    ::

        from anyblok.declarations import Declarations
        from anyblok.column import Color


        @Declarations.register(Declarations.Model)
        class Test:

            x = Color(default='green')

    """
    def __init__(self, *args, **kwargs):
        self.max_length = max_length = kwargs.pop('size', 20)
        kwargs.pop('type_', None)
        self.sqlalchemy_type = ColorType(max_length)
        super(Color, self).__init__(*args, **kwargs)

    def setter_format_value(self, value):
        if isinstance(value, str):
            value = self.sqlalchemy_type.python_type(value)

        return value

    def autodoc_get_properties(self):
        res = super(Color, self).autodoc_get_properties()
        res['size'] = self.max_length
        return res
示例#3
0
文件: column.py 项目: Gnonpi/AnyBlok
class Color(Column):
    """Color column.
    `See coulour pakage <https://pypi.python.org/pypi/colour/>`_

    ::

        from anyblok.declarations import Declarations
        from anyblok.column import Color


        @Declarations.register(Declarations.Model)
        class Test:

            x = Color(default='green')

    """
    def __init__(self, *args, **kwargs):
        self.max_length = max_length = kwargs.pop('size', 20)
        kwargs.pop('type_', None)
        self.sqlalchemy_type = ColorType(max_length)
        super(Color, self).__init__(*args, **kwargs)

    def setter_format_value(self, value):
        if isinstance(value, str):
            value = self.sqlalchemy_type.python_type(value)

        return value

    def autodoc_get_properties(self):
        res = super(Color, self).autodoc_get_properties()
        res['size'] = self.max_length
        return res
示例#4
0
class Color(Column):
    """Color column.
    `See coulour pakage <https://pypi.python.org/pypi/colour/>`_

    ::

        from anyblok.declarations import Declarations
        from anyblok.column import Color


        @Declarations.register(Declarations.Model)
        class Test:

            x = Color(default='green')

    """

    def __init__(self, *args, **kwargs):
        max_length = kwargs.pop("size", 20)

        if "type_" in kwargs:
            del kwargs["type_"]

        if "foreign_key" in kwargs:
            self.foreign_key = kwargs.pop("foreign_key")

        self.sqlalchemy_type = ColorType(max_length)
        super(Color, self).__init__(*args, **kwargs)

    def setter_format_value(self, value):
        if isinstance(value, str):
            value = self.sqlalchemy_type.python_type(value)

        return value
示例#5
0
    def __init__(self, *args, **kwargs):
        max_length = kwargs.pop("size", 20)

        if "type_" in kwargs:
            del kwargs["type_"]

        if "foreign_key" in kwargs:
            self.foreign_key = kwargs.pop("foreign_key")

        self.sqlalchemy_type = ColorType(max_length)
        super(Color, self).__init__(*args, **kwargs)
示例#6
0
    def __init__(self, *args, **kwargs):
        max_length = kwargs.pop('size', 20)

        if 'type_' in kwargs:
            del kwargs['type_']

        if 'foreign_key' in kwargs:
            self.foreign_key = kwargs.pop('foreign_key')

        self.sqlalchemy_type = ColorType(max_length)
        super(Color, self).__init__(*args, **kwargs)
示例#7
0
文件: column.py 项目: AnyBlok/AnyBlok
class Color(Column):
    """Color column.
    `See colour package on pypi <https://pypi.python.org/pypi/colour/>`_

    ::

        from anyblok.declarations import Declarations
        from anyblok.column import Color


        @Declarations.register(Declarations.Model)
        class Test:

            x = Color(default='green')

    """
    def __init__(self, *args, **kwargs):
        self.max_length = max_length = kwargs.pop('size', 20)
        kwargs.pop('type_', None)
        self.sqlalchemy_type = ColorType(max_length)
        super(Color, self).__init__(*args, **kwargs)

    def setter_format_value(self, value):
        """Format the given value

        :param value:
        :return:
        """
        if isinstance(value, str):
            value = self.sqlalchemy_type.python_type(value)

        return value

    def autodoc_get_properties(self):
        """Return properties for autodoc

        :return: autodoc properties
        """
        res = super(Color, self).autodoc_get_properties()
        res['size'] = self.max_length
        return res

    def get_encrypt_key_type(self, registry, sqlalchemy_type, encrypt_key):
        sqlalchemy_type = StringEncryptedType(sqlalchemy_type, encrypt_key)
        if sgdb_in(registry.engine, ['MySQL', 'MariaDB']):
            sqlalchemy_type.impl = types.String(max(self.max_length, 64))

        return sqlalchemy_type
示例#8
0
 def __init__(self, *args, **kwargs):
     self.max_length = max_length = kwargs.pop('size', 20)
     kwargs.pop('type_', None)
     self.sqlalchemy_type = ColorType(max_length)
     super(Color, self).__init__(*args, **kwargs)
示例#9
0
文件: column.py 项目: Gnonpi/AnyBlok
 def __init__(self, *args, **kwargs):
     self.max_length = max_length = kwargs.pop('size', 20)
     kwargs.pop('type_', None)
     self.sqlalchemy_type = ColorType(max_length)
     super(Color, self).__init__(*args, **kwargs)