示例#1
0
    def __init__(self, source):
        super(MyEditor, self).__init__(source, self.fields)

        self.name.validate(lambda v: validator.to_string(v, strip=True).
                           not_empty().to_string())
        self.age.validate(lambda v: validator.to_int(v).lesser_than(50).
                          greater_than(0).to_int())
示例#2
0
 def __init__(self, title, description, save_template_func):
     self.save_template_func = save_template_func
     self.title = editor.Property(title)
     self.title.validate(
         lambda v: nagare_validator.to_string(v).not_empty())
     self.description = editor.Property(description)
     self.shared = editor.Property(False).validate(validator.BoolValidator)
示例#3
0
    def __init__(self, name):
        """Initialization

        In:
          - ``name`` -- initial value of the text field
        """
        # Create a property. The text must be not empty
        self.name = editor.Property(name).validate(validator.to_string(strip=True).not_empty())
示例#4
0
    def __init__(self, names):
        """Initialization

        Create an editor property for each names

        In:
          - ``names`` -- list of name to edit
        """
        self.names = [editor.Property(name).validate(validator.to_string(strip=True).not_empty()) for name in names]
示例#5
0
    def __init__(self, name):
        """Initialization

        In:
          - ``name`` -- initial value of the text field
        """
        # Create a property. The text must be not empty
        self.name = editor.Property(name).validate(
            validator.to_string(strip=True).not_empty())
示例#6
0
    def __init__(self):
        self.title = editor.Property(None)
        self.img = editor.Property(None)

        # The validation functions are added:
        #
        #   - the title must be a not empty string
        #   - a image must be uploaded
        self.title.validate(validator.to_string().not_empty().to_string())
        self.img.validate(self.validate_img)
示例#7
0
文件: comp.py 项目: amatthi/mazik
    def __init__(self, columns_count):
        """Initialization

        In:
            - ``board`` -- the board the new column will belong
        """
        self.columns_count = columns_count
        self.index = editor.Property(u'').validate(nagare_validator.to_int)
        self.title = editor.Property(u'')
        self.title.validate(lambda v: nagare_validator.to_string(v.strip()).not_empty(_(u'''Can't be empty''')))
        self.nb_cards = editor.Property(u'').validate(self.validate_nb_cards)
示例#8
0
    def __init__(self, columns_count):
        """Initialization

        In:
            - ``board`` -- the board the new column will belong
        """
        self.columns_count = columns_count
        self.index = editor.Property(u'').validate(nagare_validator.to_int)
        self.title = editor.Property(u'')
        self.title.validate(lambda v: nagare_validator.to_string(v).not_empty(_(u'''Can't be empty''')))
        self.nb_cards = editor.Property(u'').validate(self.validate_nb_cards)
示例#9
0
    def __init__(self, names):
        """Initialization

        Create an editor property for each names

        In:
          - ``names`` -- list of name to edit
        """
        self.names = [
            editor.Property(name).validate(
                validator.to_string(strip=True).not_empty()) for name in names
        ]
示例#10
0
    def __init__(self, target):
        """Initialization

        Create a ``editor.property`` for each ``self.fields`` of the target object

        In:
          - ``target`` -- the object to edit
        """
        super(FormEditor, self).__init__(target, self.fields)

        # Set the conversion and validation rules on the properties
        self.age.validate(validator.to_int().lesser_than(50).greater_than(10))
        self.area.validate(validator.to_string(strip=True).not_empty().match(r'^[a-d]+$'))

        # A property can also be manually created
        self.file = editor.Property().validate(self.validate_file)

        # An editor can have more properties than the attributes of the target object
        self.confirm = editor.Property('').validate(self.validate_confirm)
示例#11
0
    def __init__(self, target):
        """Initialization

        Create a ``editor.property`` for each ``self.fields`` of the target object

        In:
          - ``target`` -- the object to edit
        """
        super(FormEditor, self).__init__(target, self.fields)

        # Set the conversion and validation rules on the properties
        self.age.validate(validator.to_int().lesser_than(50).greater_than(10))
        self.area.validate(
            validator.to_string(strip=True).not_empty().match(r'^[a-d]+$'))

        # A property can also be manually created
        self.file = editor.Property().validate(self.validate_file)

        # An editor can have more properties than the attributes of the target object
        self.confirm = editor.Property('').validate(self.validate_confirm)
示例#12
0
 def __init__(self, source):
     super(MyStringEditor4, self).__init__(source)
     self.name.validate(
         lambda v: validator.to_string(v, strip=True).length_equal(
             5, msg="test7 - Length must be %(len)d characters"))
示例#13
0
 def __init__(self, source):
     super(MyStringEditor3, self).__init__(source)
     self.name.validate(
         lambda v: validator.to_string(v, strip=True).shorter_than(
             5,
             msg="test6 - Length must be shorter than %(max)d characters"))
示例#14
0
 def __init__(self, source):
     super(MyStringEditor2, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).match(
         r'^[a-d]+$', msg="test5 - Incorrect format"))
示例#15
0
    def __init__(self, source):
        super(MyStringEditor1, self).__init__(source)

        self.name.validate(
            lambda v: validator.to_string(v, strip=True).not_empty())
示例#16
0
 def __init__(self, source):
     super(MyStringEditor5, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).longer_than(5).shorter_or_equal_than(8).not_empty().match(r'^[1-9]+$'))
示例#17
0
    def __init__(self):
        self.title = editor.Property(None)
        self.img = editor.Property(None)

        self.title.validate(validator.to_string().not_empty().to_string())
        self.img.validate(self.validate_img)
示例#18
0
 def __init__(self, source):
     super(MyStringEditor3, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).shorter_than(5, msg="test6 - Length must be shorter than %(max)d characters"))
示例#19
0
    def __init__(self, source):
        super(MyEditor, self).__init__(source, self.fields)

        self.name.validate(lambda v: validator.to_string(v, strip=True).not_empty().to_string())
        self.age.validate(lambda v: validator.to_int(v).lesser_than(50).greater_than(0).to_int())
示例#20
0
 def __init__(self, source):
     super(MyStringEditor2, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).match(r'^[a-d]+$', msg="test5 - Incorrect format"))
示例#21
0
 def __init__(self, title, description, save_template_func):
     self.save_template_func = save_template_func
     self.title = editor.Property(title)
     self.title.validate(lambda v: nagare_validator.to_string(v).not_empty())
     self.description = editor.Property(description)
     self.shared = editor.Property(False).validate(validator.BoolValidator)
示例#22
0
 def __init__(self, source):
     super(MyStringEditor5, self).__init__(source)
     self.name.validate(
         lambda v: validator.to_string(v, strip=True).longer_than(
             5).shorter_or_equal_than(8).not_empty().match(r'^[1-9]+$'))
示例#23
0
 def __init__(self, source):
     super(MyStringEditor4, self).__init__(source)
     self.name.validate(lambda v: validator.to_string(v, strip=True).length_equal(5, msg="test7 - Length must be %(len)d characters"))
示例#24
0
    def __init__(self, source):
        super(MyStringEditor1, self).__init__(source)

        self.name.validate(lambda v: validator.to_string(v, strip=True).not_empty())
示例#25
0
文件: gallery6.py 项目: jean/examples
    def __init__(self):
        self.title = editor.Property(None)
        self.img = editor.Property(None)

        self.title.validate(validator.to_string().not_empty().to_string())
        self.img.validate(self.validate_img)