On Wed, Dec 3, 2008 at 2:56 PM, Jorge Vargas <[EMAIL PROTECTED]> wrote: > > On Tue, Dec 2, 2008 at 8:38 AM, Helio Pereira > <[EMAIL PROTECTED]> wrote: >> >> Hi all >> >> I have this in my controller to control all important downloads in >> tg2: http://paste.turbogears.org/paste/15338 >> Is this the best way to do it? >> >> Many thanks for all, >> Helio Pereira >> > that works although you may want to take a look at paste.fileapp, as > it is more robust sending headers for modified and such. Here is an > example. > http://paste.chrisarndt.de/paste/99e8dbf02a4e4af5bd365ef722de2c69?wrap=no > > docs for fileapp are thin http://pythonpaste.org/modules/fileapp.html > but if you look at the code it's far more robust than your custom > implementation. You may also want to take a look at DirectoryApp.
hm, I've just worked on a similar controller today using TG1.0.X but I had two problems with the approach mentioned in the docs (http://docs.turbogears.org/1.0/FileUploadTutorial#add-the-download-method) which looks very similar to the example from above. The first thing is that the files I have to deliver are stored in the database and it looks like that both functions expect the file somewhere in the file system. I had a quick look at the CP sources and it seems that there's no handy function that sets proper headers when using file-like objects. I don't know the sources for fileapp, but according to the example above it should be similar. The other thing is more a question than a "real" problem. Shouldn't be the filename in the Content-Disposition header encoded according to RFC 2231 if it contains characters other than US_ASCII? AFAICT serve_file() don't handle that case, but at least I'm not sure if it's really required to follow RFC 2231... Does anyone know a convenient way to server files (possibly with non-US_ASCII chars in the file name) stored in a database with automagically good-looking headers for TurboGears 1.0? Andi > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

