Ejemplo n.º 1
0
class FileFieldSet(FieldSet):
    '''FieldSet aggregating fields required for file upload handling::
    '''

    fields = [
        FileField('file', conv=convs.SimpleFile(), widget=widgets.FileInput()),
        Field('mode',
              conv=convs.EnumChoice(choices=[('existing', ''),
                                             ('transient', ''), ('empty', '')],
                                    required=True),
              widget=widgets.HiddenInput),
        Field('transient_name',
              conv=convs.Char(check_file_path, required=False),
              widget=widgets.HiddenInput),
        Field('original_name',
              conv=convs.Char(check_file_path, required=False),
              widget=widgets.HiddenInput),
    ]

    conv = FileFieldSetConv

    def __init__(self, name, **kwargs):
        kwargs.setdefault('fields', self.fields)
        kwargs.setdefault('conv', self.conv)
        FieldSet.__init__(self, name, **kwargs)

    def get_initial(self):
        # Redefine because FieldSet.get_initial returns dict by default,
        # but python value of FileFieldSet is either None, either BaseFile
        # instance.
        return None
Ejemplo n.º 2
0
 class F(Form):
     fields = [
         Field('name',
               conv=convs.Char(),
               widget=self.widget(classname="cls")),
         Field('unreadable',
               permissions="w",
               conv=convs.Char(),
               widget=self.widget(classname="cls"))
     ]
Ejemplo n.º 3
0
 class F(Form):
     fields = [
         Field('name',
               conv=convs.Char(),
               widget=self.widget(
                   getter=lambda x: x.replace('value', 'display')))
     ]
Ejemplo n.º 4
0
class CF_CheckboxField(CF_EnumField):
    multiple = True
    conv = CF_EnumChoiceConv(conv=convs.ListOf(convs.Char()))
    widget = CF_CheckboxWidget()

    @cached_property
    def json_prepared(self):
        return u', '.join(self.clean_value)
Ejemplo n.º 5
0
 class F(Form):
     fields = [
         Field(
             'name',
             conv=convs.Char(),
             widget=self.widget(),
             permissions="r",
         )
     ]
Ejemplo n.º 6
0
class CF_TextareaField(CF_FormField):
    widget = CF_TextAreaWidget()
    conv = convs.Char(convs.length(1, 2000))

    size_classnames = {
        'small': 'textarea_small',
        'medium': 'textarea_medium',
        'large': 'textarea_large'
    }
Ejemplo n.º 7
0
 class _Form(Form):
     fields = [
         FieldBlock('field block',
                    fields=[
                        Field('number', convs.Int()),
                        Field('title', convs.Char()),
                    ],
                    permissions='r'),
     ]
Ejemplo n.º 8
0
 class _Form(Form):
     fields = [
         FieldBlock('field block', [
             Field('number', convs.Int()),
             FieldBlock('field block', [
                 Field('title', convs.Char()),
             ]),
         ]),
     ]
Ejemplo n.º 9
0
 class F(Form):
     fields = [
         FieldList('list',
                   field=FieldSet(None,
                                  fields=[
                                      Field('name',
                                            conv=convs.Char(),
                                            widget=widgets.TextInput)
                                  ]))
     ]
Ejemplo n.º 10
0
 def _item_field(self, models, factory=None):
     return IF_StreamSelect(
         self.name,
         label=self.label,
         model=self.model,
         stream_name=self.stream_name,
         multiple=self.multiple,
         allow_create=self.allow_create,
         allow_select=self.allow_select,
         allow_delete=self.allow_delete,
         inshift=self.inshift,
         condition=self.condition,
         default_filters=self.default_filters,
         ordered=self.ordered,
         rel=self.rel,
         conv=convs.Char()
     )
Ejemplo n.º 11
0
 class F(Form):
     fields = [Field('name', conv=convs.Char(), widget=self.widget())]
Ejemplo n.º 12
0
 class F(Form):
     fields = [
         Field('name',
               conv=convs.Char(),
               widget=self.widget(escape=False))
     ]
Ejemplo n.º 13
0
 class _Form(Form):
     fields = [Field('input', convs.Char())]