python - How to make file upload facultative with Deform and Colander? -


i render form containing sequence of files, representing different images of product. providing files should facultative, form should validate in absence of files. how can ?

here colander schema use:

    import colander     import deform     deform import form     deform import validationfailure     deform.interfaces import fileuploadtempstore        tmpstore = fileuploadtempstore()      class image(colander.schema):         image = colander.schemanode(             deform.filedata(),             widget=deform.widget.fileuploadwidget(tmpstore)             )       class images(colander.sequenceschema):         images = image()      class productschema(colander.schema):         completename = colander.schemanode(colander.string(), title="complete name")          description = colander.schemanode(colander.string(),                                   widget = deform.widget.textareawidget())          images = images()       schema = productschema()     form = form(schema, buttons=("submit", )) 

i tried add 'missing' argument like:

image = colander.schemanode(         deform.filedata(),         missing = ???         widget=deform.widget.fileuploadwidget(tmpstore)         )  

i think functional when

missing={'filename': none, 'uid':none} 

but i'm not sure it's correct way it...

thanks !

you might try "missing = colander.null".


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -