[reportlab-users] Generic mod_python error when returning pdf

Simone Dalmasso simone.dalmasso at gmail.com
Tue Oct 13 08:44:54 EDT 2009


Looking for the error stacktrace this is what I get:

Traceback (most recent call last):

File "/usr/lib64/python2.4/site-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)

File "/usr/lib64/python2.4/site-packages/mod_python/importer.py",
line 1229, in _process_target
result = _execute_target(config, req, object, arg)

File "/usr/lib64/python2.4/site-packages/mod_python/importer.py",
line 1128, in _execute_target

result = object(arg)

File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py",
line 228, in handler
return ModPythonHandler()(req)

File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py",
line 201, in __call__

response = self.get_response(request)

File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py",
line 128, in get_response
return self.handle_uncaught_exception(request, resolver, exc_info)

File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py",
line 160, in handle_uncaught_exception
return callback(request, **param_dict)

File "/usr/lib/python2.4/site-packages/django/views/defaults.py",
line 23, in server_error

t = loader.get_template(template_name) # You need to create a
500.html template.

File "/usr/lib/python2.4/site-packages/django/template/loader.py",
line 80, in get_template
source, origin = find_template_source(template_name)

File "/usr/lib/python2.4/site-packages/django/template/loader.py",
line 73, in find_template_source
raise TemplateDoesNotExist, name

TemplateDoesNotExist: 500.html

I have't designed the 550 error template yet. But anyway it isn't so useful
I think. Trying to execute the method through the python shell it doesn't
raise any exceptions and it returns an HttpResponse object. So I think that
the error occurs when django tries to send the response to the client. Maybe
some issues between django and mod_python?

Simone



2009/10/13 Robin Becker <robin at reportlab.com>


> Simone Dalmasso wrote:

>

>> Hi, list. Months ago I built a web app under django which through a

>> button

>> creates a pdf and returns it via an HttpResponse. All worked fine util the

>> app was under the django development server but now, trying to deploy

>> under

>> mod_python, it breaks when the server try to send the pdf. What I get is a

>> generic mod_python error.

>> The way I create the pdf is like this:

>> response = HttpResponse(mimetype = "application/pdf")

>> response['Content-Disposition'] = 'attachment;

>> filename=Fasst-laboratories.pdf'

>> doc = SimpleDocTemplate(response, topMargin = 1 *cm)

>> and more...

>> then I return the response variable to another method which handle the

>> http

>> request and sends back the response to the client.

>>

>> ........

>

> effectively you are relying on SimpleDocTemplate to write into the

> response; according to my understanding that should work. However, without

> knowing what the error is makes it hard to figure out what mod_python is

> whining about. Have you looked in the apache error logs to see if there's

> anything obvious going on.

>

> A few years ago when we started with django we used mod_python, but several

> things put us off. Firstly we had problems related to tight binding of

> apache/python/os etc etc and thene teher were issues about separation of

> virtual hosts; at one pint we used a two layer scheme with the VMs on the

> top layer passing to individual apaches running the applications with a

> mod_python for each.

>

> We eventually switched to fastcgi using flup. That has proved very flexible

> and stable and allows us to use different versions of django python etc etc.

> --

> Robin Becker

> _______________________________________________

> reportlab-users mailing list

> reportlab-users at lists2.reportlab.com

> http://two.pairlist.net/mailman/listinfo/reportlab-users

>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20091013/a08d6a57/attachment.html>


More information about the reportlab-users mailing list