[reportlab-users] SQL ReportLab Example Question..
John Pywtorak
jpywtora at calpoly.edu
Tue Aug 16 12:27:10 EDT 2005
longoal at optonline.net wrote:
> I am trying to get an example on how to incorporate a data recordset with ReportLab.
>
> One way that I was thinking about doing this was:
>
> 1. Open a file stream Or Python Report Source(ie; .py file)
> 2. Write all the ReportLab headings i.e; import .....
> 3. Write to the file and open up a DATA declaration.(ie. data = (
> ('', 'Jan',
> 4. Open a recordset and iterate and append to the DATA declaration.
> 5. close the DATA declaration and close the .py file
> 6. Shell execute the file which should create the "PDF" file.
>
> Any ideas on how to do this a different way?
> Thanks in advance,
> AL
> ps. currently getting data from Oracle 10g Database using OCI and ASP/IIS.
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
Ok, first let me say what I think you are asking. You want to
dynamically generate a python script that upon execution (CreateProcess
or ShellExecute, etc) will then generate a pdf file that you can stream
back to the user?
I can only assume that since you are using ASP/IIS you want to do this
from JScript, or VBScript. Back in the day I was a Win32, COM, ASP
developer, so I think I have a feel for what you want to do. I am glad
those days are gone, but that is another story.
Assuming all the above is close enough let me make some comments. From
above numbers 1, 2, 3, 4, and 5 are all reasonable; However, #6 is the
gotcha in a web environment.
How do you make sure the process that you shell execute is not in a
deadlock? The web client would timeout, is that what you want and the
webserver would have at least one thread tied up potentially increasing
memory and cpu utilization until the server goes down.
It is one thing to whip up an asp script that executes something. It is
a whole different game to make that robust and scalable. I hope you can
see what I am talking about. I once wrote a COM object that did exactly
this. It would kick off an external executable, monitor it, capture its
output, and if the thing did not execute fast enough it would inject a
thread into the running process that would call exit. This was no easy
task, but it was robust and scalable.
With all that said I would highly encourage you to allow IIS to run
python scripts. Use CGI at a minimum, or any of the other fine python
WSGI web frameworks. This would eliminate the complexity of dynamically
generated code, or code that writes code. The asp can forward, or
redirect to the python script url, then once the pdf is done it can
redirect, or forward back to asp scripts.
This would put your web app code much closer to the metal and lower the
complexity of your app. Remember when executing a process via shell
execute, or other you only have PIPES, stdin, stdout, stderr, to
communicate with it. PIPES can be tricky and more than likely the
complexity of adding another IPC mechanism is more than you want to
tackle at this moment. Let IIS run your python script ;-)
Johnny P
--
Windows
Start Here
Frustrating Hanging Crashing
Blue Screen of Death
Reboot
More information about the reportlab-users
mailing list