Kevin Horn wrote:
> Well, if validation fails, then program flow will go to your
> @error_handler method (in this case, wholesaleMargin), so you would
> need to look there to see what's happening. Does wholesaleMargin()
> have a return value? It doesn't look like it from your code...
>
> Of course, reading this:
> http://docs.turbogears.org/1.0/ValidateDecorator ...
> "When the arguments, for whatever reason, fail validation, you will
> receive no values for the failing arguments."
>
> So it seems that what I suggested earlier isn't going to work in any
> case. My guess is that validation is failing somehow, and that's
> causing some of your arguments to not have a value, which is messing
> up your PDF generation somehow. Or something.
>
> Where is the error message coming from? Figuring out where that is
> being generated would go a long ways towards diagnosing your problem.
>
> Kevin Horn
>
> On 3/15/07, * Jim Steil* <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>> wrote:
>
> Kevin Horn wrote:
>> 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]
>> <mailto:[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
>>
>> <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
>>
>>
>>
>>
>>
>>
>>
> The problem there is that I never even get into the code in the
> method. If I put a log.debug(kw) as the first line of the code,
> it never gets there. It is skipping over the entire method and
> returning nothing.
>
>
>
> >
The error message that I'm receiving is coming from the Adobe Acrobat
PDF reader. I'm assuming that is because of the
@tg.expose(content_type="application/pdf"). Could it be that it is
redirecting me to the error_handler but the content type is trying to
render it as a PDF?
-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
-~----------~----~----~----~------~----~------~--~---