Graham - i think his code will be attempting to create the file open\ Patient_info.pdf in the current working directory, and therefore as root it may work without error? ???
MrKiwi On Oct 6, 8:55 pm, Graham Dumpleton <[email protected]> wrote: > There are couple of problems at least with what you are trying to do. > > First, you can't use relative paths to files. The current working > directory of the process will not be where your source code is. > > Second, the line: > > os.open("open Patient_info.pdf") > > isn't going to work because os.open() takes a file name not a command > and also requires a second argument even when opening a file. > > So, you should be getting errors. That you are not suggests you > haven't even set up mod_wsgi write to run this WSGI application. It > could even be because you don't even have an application object in the > code, although I'll give you the benefit of the doubt there and > presume this is only a snipper from larger code base. If it is because > of the latter, you will see errors in the Apache error log. > > Suggest you go back to basics and get a WSGI hello world program > running and as has been suggested before, don't do stuff from scratch, > use a framework such as Flask. > > Graham > > On 6 October 2011 18:28, nitin chandra <[email protected]> wrote: > > > > > > > > > Hi All, > > > I am looking to generate a PDF page from the data submitted in a web form. > > > For this I am using REportLab. > > > from reportlab.lib.pagesizes import letter > > from reportlab.pdfgen import canvas > > > class Handler: > > def do(self, environ, start_response): > > form = cgi.FieldStorage(fp=environ['wsgi.input'], > > environ=environ) > > > html = """ > > <meta http-equiv="refresh" > > content="0;url=https://www.mywebsite.in/home.py" /> """ > > > printpdf = form.getvalue('print') ## This is a checkbox in > > html { If checked then create the PDF file} > > if printpdf == 1: > > c = canvas.Canvas('Patient_info.pdf', pagesize=letter) > > c.setFont('Helvetica', 12) > > c.drawString(30,750, ptbn) > > c.showPage() > > c.save() > > os.open("open Patient_info.pdf") > > > output = html > > mimeType = "text/html" > > > status = "200 OK" > > response_headers = [("Content-type", mimeType), > > ("Content-length", str(len(output)))] > > > start_response(status, response_headers) > > return [output] > > > If i enter the code in python prompt, from c = canvas .... , a PDF > > file is created and saved in the current working directory. > > > But not when I am doing it from a webpage.py file. There is no error, > > the PDF web page / Acroread does not open / launch the page. > > > Do I need to add / change some thing, if wsgi requires it, in the > > above code to generate the PDF file ? If yes, then how should the line > > be written? > > > Thank you > > > Nitin > > > -- > > You received this message because you are subscribed to the Google Groups > > "modwsgi" 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 > > athttp://groups.google.com/group/modwsgi?hl=en. -- You received this message because you are subscribed to the Google Groups "modwsgi" 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/modwsgi?hl=en.
