Since it works fine without the validation, I would suspect that the validation process is changing a variable in some way that screws up the PDF rendering process. Try sending the output to a file (in addition to rendering it to the browser) both with and without the decorators, and compare the results.
Also see if you can get the variables that are being handled by your form, both with and without validation and compare those. Kevin Horn On 3/14/07, Jim Steil <[EMAIL PROTECTED]> wrote: > > > Hi: > > I'm writing a function that generates a pdf and displays it to the > screen. Thanks to Timothy Freund for his tutorial on how to do this. > It can be found here: > > > http://achievewith.us/public/articles/2007/02/21/produce-pdf-pages-with-turbogears-cheetah-and-reportlab > > > However, I'm having a problem. In the section of code labeled > pdfdemo.controllers.Root.letters(), I'm trying to add the validate and > error_handler decorators to validate some input I need for the report. > My code works fine without the decorators but fails with the > decorators. I'm using Windows and Firefox and here is the error I get > when I try it: > > File does not begin with '%PDF-'. > > Here is the code in my controller: > > @tg.expose(content_type="application/pdf") > @tg.validate(form=qlfFields.wholesaleMarginWidget) > @tg.error_handler(wholesaleMargin) > def wholesaleMarginReport(self, *args, **kw): > fromDate = kw['fromDate'] > toDate = kw['toDate'] > letters_file = StringIO.StringIO() > wm.wholesaleMargin(letters_file, fromDate, toDate) > pdf = letters_file.getvalue() > letters_file.close() > > return(pdf) > > This works fine if I remove the validate and error_handler decorators. > Any ideas, clues on where I should be looking? > > -Jim > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

