Last night, I was getting frustrated by my attempts to add a new table to
my, one that would use uploaddirectory on an upload field to direct the
associated files to a separate store from that of an existing table (that
used the default of 'uploads'). Shreds of hair, tumblers of tea, scours of
the newsgroup, re-reading the entry in the online manual ... still going to
uploads.
Finally, I noticed that I had missed that a line had more than one place to
change:
data=request.body.read()
logger.debug("newtable.post: from %s len data %d" %
(request.client,len(data)))
# see
https://groups.google.com/d/msg/web2py/9UO3lP7Jmgk/tv98DecbmCwJ
filedata=cStringIO.StringIO(data)
x = db.newtable.validate_and_insert(posttime = datetime.datetime.now
(), c_ip = request.client, fname=fname, fdata=db.oldtable.fdata.store(
filedata, fname), fsize=len(data))
Ooops!
I have the faint hope that this cautionary tale will help someone else
sleep better some day in the future. Yes, I know that many use the magic
of the upload field to handle the job, but for those needing the explicit
stream, here's some pixie dust.
Dave
/dps
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.