Failing silently under lighttpd?

37 views
Skip to first unread message

KenCorey

unread,
Sep 10, 2009, 12:11:34 PM9/10/09
to Pisa XHTML2PDF Support
Hi All,

I was wondering if I could get some advice on trying to debug a new
installation.

I've had pisa working just dandy on ubuntu on a 2.6.28 kernel, 2.6.2
python, etc. The PDF file is generated from within the web site just
as I might hope for.

I then got an account on vps.net, and created a Ubuntu 8.04 (2.6.24-23-
xen kernel, 2.5.2 python, etc).

I've got my application running under lighttpd, and I have fcgi-debug
running, so I can see the whole conversation between the webserver and
the application.

The xhtml is being generated ust fine, and then it's handed off to
pisa. Pisa hands back an empty PDF file. There are no errors listed
on stdout, nothing in the logs, etc. Just a single blank sheet PDF.

I created a script to take the sample files, and convert them all to
PDFs. That runs just fine. I took a look at the html that I'm
passing in to the CreatePDF function, and when I use the script above
to convert the PDF, it works like a charm...so I'm thinking I've got
pisa installed more or less correctly.

I'm stumped. Anyone know where to start debugging this? I do have
showLogging(debug=True) set, but I'm not getting anything wrong.

Thanks,

-Ken

KenCorey

unread,
Sep 12, 2009, 11:04:12 AM9/12/09
to Pisa XHTML2PDF Support
Just to provide a bit more information, I created a brand-new Ubuntu
8.04 VPS on vps.net, and then documented the steps I took to get the
web site ready to use. I ended up exactly at the same place...(when
called from the command line xhtml2pdf will perfectly convert the
xhtml content generated by my web app, when my web app calls
pisaDocument to generate the PDF, it does not work (though the same
code works on my development machine).

What I'm looking for are suggestions on how to tweak pisa to tell me
more about what's going on here. I've put output statements in the
pisa_document.py file to indicate where things get to...and it all
seems to be going well. No errors generated, no exceptions thrown.
For the record, a TOC is built, so it would be calling doc.multiBuild
(c.story). I've called pisaDocument with xhtml=1, capacity=-1, and
show_error_as_pdf=1, just in case.

I'm still stumped, so any suggestions would be greatly appreciated.

-Ken

-----------------------------------------------------------------------------------------------------------------
The steps to get a server to this state:
apt-get install lighttpd
apt-get install python-setuptools
easy_install web.py
easy_install pisa
apt-get install links
apt-get install libfreetype6
apt-get install gcc
apt-get install libart-2.0-2
apt-get install build-essential
apt-get install python-dev
apt-get install python-flup
links http://reportlab.com (download ReportLabs 2.3)
(unpack ReportLabs 2.3)
apt-get install libttf2
cd /src/ReportLab...
python setup.py install
easy_install -U xlrd
easy_install pyPdf
apt-get install python-imaging

copy the /etc/lighttpd/conf-enabled/* to the new machine.
copy the /var/app and /var/www to the new machine.

restart lighttpd so it can pick up /etc/lighttpd/conf-enabled/10-
fastcgi, which links the app in.

mkdir /var/egg
chmod 777 /var/egg
chown www-data:www-data /var/app/dbstore.db

edit /etc/passwd and change the shell for www-data to bash

apt-get install libsqlite3-dev
easy_install -U pysqlite

apt-get install python-html5lib
------------------------------------------------------------------------------------------------------
So, at this point, the xhtml2pdf command line successfully converts,
but the same thing attemped by my web app doesn't work.

Please help!

-Ken

KenCorey

unread,
Sep 12, 2009, 11:11:12 AM9/12/09
to Pisa XHTML2PDF Support
Further, I don't think it's a permissions problem. using fcgi-debug,
the process that serves the response is driven from the command line
(where the 'xhtml2pdf' command works), and is run by user 'root'.
Still 1 blank pdf file, but no errors reported.

*grrrrr*

-Ken

KenCorey

unread,
Sep 16, 2009, 6:02:24 AM9/16/09
to Pisa XHTML2PDF Support
This was a very strange thing, especially to a Python newbie such as
me.

The xhtml2pdf command was generating the document just fine...but the
execution was failing silently.

What seems to have been happenning is that the html parser was being
called with the descriptor of the string object (<StringIO::StringIO
at 0xfbe4564>), rather than the contents of the string
(<html><head>...) object. This caused htmlparser to die with a
"expected-doctype-but-got-eof".

So, on pisa_parser.py, line 615, I changed

document = parser.parse(
src,
encoding=encoding)

to

document = parser.parse(
src.getvalue(), #<------changed.
encoding=encoding)

and it works just fine again.

Apparently xhtml2pdf now dies, because file objects have no 'getvalue'
method.

I don't know if it's a bug in pisa (it's certainly frustrating, as I
ended up spending several days on it), or just in the way I'm calling
pisa...but it's fixed for me now, I don't really care.

-Ken

ViNOJ

unread,
Apr 8, 2014, 12:52:44 AM4/8/14
to xhtm...@googlegroups.com
Thanks mate, I had similar issue it worked perfect after changes suggested by you.
Can anyone explain this issue, whether this is a bug or something..
Just curious to know though my problem has been solved...
ViNOJ
Reply all
Reply to author
Forward
0 new messages