web/formfields.py
changeset 5762 730d458ec1bf
parent 5712 e136d392bd71
parent 5756 ab03e4adb4f1
child 5816 5d72fbba92e9
equal deleted inserted replaced
5754:51179e0bb250 5762:730d458ec1bf
    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 = []
   740         value = Binary(stream.read())
   742         value = Binary(stream.read())
   741         if not value.getvalue(): # usually an unexistant file
   743         if not value.getvalue(): # usually an unexistant file
   742             value = None
   744             value = None
   743         else:
   745         else:
   744             # set filename on the Binary instance, may be used later in hooks
   746             # set filename on the Binary instance, may be used later in hooks
   745             value.filename = filename
   747             value.filename = normalize_filename(filename)
   746         return value
   748         return value
   747 
   749 
   748 
   750 
   749 # XXX turn into a widget
   751 # XXX turn into a widget
   750 class EditableFileField(FileField):
   752 class EditableFileField(FileField):