File upload problem

"Mike Orr" <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
I can't figure out what's wrong with this form.  I try to upload a
file but it acts like nothing was uploaded.  Yet the same code
structure in another site works fine.  I'm getting the same problem in
both Firefox and Konqueror.

Note how it says the upload object is None, and the raw input for the
parameter appears to be the filename.

Quixote 2.4 on Linux.

-- 
Mike Orr <[email protected]>

_______________________________________________
Quixote-users mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-users
upload_form.py (application/octet-stream, 1.2 KB)
#!/usr/bin/env python
import pprint
import quixote
from quixote.publish import Publisher
from quixote.directory import Directory
from quixote.form import Form
from quixote.form import widget

class RootDirectory(Directory):

    _q_exports = ['']

    def _q_index(self):
        print "Request input is", pprint.pformat(quixote.get_request().form)
        form = ImportForm()
        if form.is_submitted():
            if form.has_errors():
                pass
            else:
                return "Upload object is %r" % form["attachment"]
        return form.render()

def ImportForm():
    mode_options = [
        ("replace", "Replace", "replace"), 
        ("append", "Append", "append")]
    form = Form()
    form.add(widget.RadiobuttonsWidget, "mode", value="replace",
        title="Mode", options=mode_options)
    form.add(widget.FileWidget, "attachment", title="File", required=False)
    form.add_submit("submit", "Import")
    return form

def create_publisher():
    return Publisher(RootDirectory(),
                     display_exceptions='html')


if __name__ == '__main__':
    from quixote.server.simple_server import run
    print 'creating demo listening on http://localhost:8080/'
    run(create_publisher, host='localhost', port=8080)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.