Latest Version: 0.9.6.2

FileUploadKeeper

Takes two inputs (a dictionary with keys static and upload) and converts them into one value on the Python side (a dictionary with filename and content keys). The upload takes priority over the static value. The filename may be None if it can't be discovered.

Handles uploads of both text and cgi.FieldStorage upload values.

This is basically for use when you have an upload field, and you want to keep the upload around even if the rest of the form submission fails. When converting back to the form submission, there may be extra values 'original_filename' and 'original_content', which may want to use in your form to show the user you still have their content around.

To use this, make sure you are using variabledecode, then use something like:

<input type="file" name="myfield.upload">
<input type="hidden" name="myfield.static">

Then in your scheme:

class MyScheme(Scheme):
    myfield = FileUploadKeeper()

Note that big file uploads mean big hidden fields, and lots of bytes passed back and forth in the case of an error.

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
noneType:
The input must be a string (not None)

Attributes

a __singletonmethods__

('to_python', 'from_python')

a accept_python

True

a compound

False

a not_empty

False

a repeating

False

a static_key

'static'

a strip

False

a upload_key

'upload'

Methods

f __call__(self, *args, **kw) ...

f __classinit__(cls, new_attrs) ...

f __classsourcerepr__(cls, source, binding=None) ...

f __init__(self, *args, **kw) ...

f __initargs__(self, new_attrs) ...

f __sourcerepr__(self, source, binding=None) ...

f pack_content(self, filename, content) ...

See the source for more information.

Top