web/formfields.py
branchstable
changeset 5367 4176a50c81c9
parent 5220 42f854b6083d
child 5368 d321e4b62a10
equal deleted inserted replaced
5366:5f116a4d8a54 5367:4176a50c81c9
    11 
    11 
    12 from warnings import warn
    12 from warnings import warn
    13 from datetime import datetime
    13 from datetime import datetime
    14 
    14 
    15 from logilab.mtconverter import xml_escape
    15 from logilab.mtconverter import xml_escape
       
    16 from logilab.common import nullobject
    16 from logilab.common.date import ustrftime
    17 from logilab.common.date import ustrftime
    17 
    18 
    18 from yams.schema import KNOWN_METAATTRIBUTES, role_name
    19 from yams.schema import KNOWN_METAATTRIBUTES, role_name
    19 from yams.constraints import (SizeConstraint, StaticVocabularyConstraint,
    20 from yams.constraints import (SizeConstraint, StaticVocabularyConstraint,
    20                               FormatConstraint)
    21                               FormatConstraint)
    43         else:
    44         else:
    44             partresult.append( (label, value) )
    45             partresult.append( (label, value) )
    45     result += sorted(partresult)
    46     result += sorted(partresult)
    46     return result
    47     return result
    47 
    48 
    48 _MARKER = object()
    49 _MARKER = nullobject()
    49 
    50 
    50 class Field(object):
    51 class Field(object):
    51     """This class is the abstract base class for all fields. It hold a bunch
    52     """This class is the abstract base class for all fields. It hold a bunch
    52     of attributes which may be used for fine control of the behaviour of a
    53     of attributes which may be used for fine control of the behaviour of a
    53     concret field.
    54     concret field.
   599             # set filename on the Binary instance, may be used later in hooks
   600             # set filename on the Binary instance, may be used later in hooks
   600             value.filename = filename
   601             value.filename = filename
   601         return value
   602         return value
   602 
   603 
   603 
   604 
       
   605 # XXX turn into a widget
   604 class EditableFileField(FileField):
   606 class EditableFileField(FileField):
   605     editable_formats = ('text/plain', 'text/html', 'text/rest')
   607     editable_formats = ('text/plain', 'text/html', 'text/rest')
   606 
   608 
   607     def render(self, form, renderer):
   609     def render(self, form, renderer):
   608         wdgs = [super(EditableFileField, self).render(form, renderer)]
   610         wdgs = [super(EditableFileField, self).render(form, renderer)]