web/formfields.py
branchstable
changeset 5756 ab03e4adb4f1
parent 5661 84ef08bbda3c
child 5762 730d458ec1bf
equal deleted inserted replaced
5755:ca9e1c9123d7 5756:ab03e4adb4f1
    80 class UnmodifiedField(Exception):
    80 class UnmodifiedField(Exception):
    81     """raise this when a field has not actually been edited and you want to skip
    81     """raise this when a field has not actually been edited and you want to skip
    82     it
    82     it
    83     """
    83     """
    84 
    84 
       
    85 def normalize_filename(filename):
       
    86     return filename.split('\\')[-1]
    85 
    87 
    86 def vocab_sort(vocab):
    88 def vocab_sort(vocab):
    87     """sort vocabulary, considering option groups"""
    89     """sort vocabulary, considering option groups"""
    88     result = []
    90     result = []
    89     partresult = []
    91     partresult = []
   734         value = Binary(stream.read())
   736         value = Binary(stream.read())
   735         if not value.getvalue(): # usually an unexistant file
   737         if not value.getvalue(): # usually an unexistant file
   736             value = None
   738             value = None
   737         else:
   739         else:
   738             # set filename on the Binary instance, may be used later in hooks
   740             # set filename on the Binary instance, may be used later in hooks
   739             value.filename = filename
   741             value.filename = normalize_filename(filename)
   740         return value
   742         return value
   741 
   743 
   742 
   744 
   743 # XXX turn into a widget
   745 # XXX turn into a widget
   744 class EditableFileField(FileField):
   746 class EditableFileField(FileField):