[mod_python] Problems with ZODB / modpython

Thiago Comicio thiagocomicio at gmail.com
Mon Jan 22 10:49:20 EST 2007


On 1/19/07, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> Followups to the mailing list please.
>
> On 19/01/2007, at 9:55 PM, Thiago Comicio wrote:
>
> > On 1/18/07, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> >> What version of mod_python are you using, is it an older version? At
> >> least upgrade to mod_python 3.2.10 if you haven't already. There are
> >> certainly bugs in mod_python 3.1.X which may cause this.
> >
> > I'm using the version 3.2.8-3.1 fo Fedora 6. I've tried to run this
> > boot script with mod_python 3.2.10 without success.
> >
> >> Also, what
> >> Apache configuration do you use for enabling mod_python for that
> >> part of the URL namespace? Do you use PythonPath or PythonImport
> >> directives?
> >
> > I didn't understand very well your question, but the PYTHONPATH is
> > used to run ZODB, which is part of ZOPE (zope-2.9.6-1.fc6).
> > My Apache configuration to access the directory with the python
> > scripts is:
> >
> > <Directory /var/www/html/indico>
> >        AddHandler python-program .py
> >        PythonHandler mod_python.publisher
> >        PythonDebug On
> > </Directory>
>
> The PYTHONPATH setting if required has to be duplicated with equivalent
> in mod_python. Ie., add:
>
>    PythonPath "sys.path+['/usr/lib/zope/lib/python']"
>

Thanks Graham, it worked and my apologies for sending you those emails.

Thiago Comicio

> Read the documentation for information about the PythonPath directive.
>
> > When I boot the computer it doesn't work, but when I restart Apache,
> > without changing any configuration, it works.
>
> It works when you do a restart as it is probably inheriting PYTHONPATH
> from your user account. The Apache startup script will not have this on
> a reboot, so you need to set it up in Apache configuration file.
>
> > I made some tests.
> > When I initialize ZODB at the startup and start Apache after logging
> > in, it works. Or, after logging in, I initialize ZODB and Apache, it
> > works too. The problem is when I initialize both at the startup, first
> > ZODB and then Apache.
> >
> > Thanks,
> >
> > Thiago Comicio
> >
> >>
> >> Graham
> >>
> >> Thiago Comicio wrote ..
> >> > On 1/17/07, Graham Dumpleton <grahamd at dscpl.com.au> wrote:
> >> > > Thiago Comicio wrote ..
> >> > > > Hi,
> >> > > >
> >> > > > I'm trying to install a program that needs mod_python and
> >> ZODB. The
> >> > > > program is not running, so I tried to connect to the
> >> database through
> >> > > > this script:
> >> > > >
> >> > > > from ZODB import FileStorage, DB
> >> > > >
> >> > > > def index(req, **params):
> >> > > >         storage = FileStorage.FileStorage('mydatabase.fs')
> >> > > >         db = DB(storage)
> >> > > >         connection = db.open()
> >> > > >         root = connection.root()
> >> > > >         return TestPage().getHTML()
> >> > > >
> >> > > > And I received the error below.
> >> > > > Does anybody know how to fix it?
> >> > >
> >> > > A couple of things to be aware of.
> >> > >
> >> > > 1. The Apache web server generally runs as a special user and
> >> thus that
> >> > user
> >> > > must have write access to the directory where you are wanting
> >> to create
> >> > the
> >> > > database.
> >> > >
> >> > > 2. The current working directory is normally '/' for the
> >> Apache processes
> >> > and
> >> > > thus if you do not specify an absolute path to where you want
> >> to store
> >> > the
> >> > > database, it will try and store it in '/' where you are
> >> unlikely to have
> >> > permissions
> >> > > to write. You should not change the working directory as if
> >> every handler
> >> > did