quetz-mod_python-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Treadway" <se...@superchannel.org>
Subject RE: inital questions and patches
Date Thu, 01 Jul 2004 08:45:07 GMT
Sorry for spam, but this was an early morning post.  You'll also need
the following "modpython.py" renderer in your Pyblosxom/renderers
directory.

"""
Standard blosxom renderer, with modified showHeaders for mod_python
"""
from Pyblosxom.renderers.blosxom import BlosxomRenderer

class BlosxomModPythonRenderer(BlosxomRenderer):
    def showHeaders(self):
        out = getattr(self._out, 'headers_out')
        for k, v in self._header.items():
            out[k] = str(v)

class Renderer(BlosxomModPythonRenderer):
    pass

### And I may as well throw in my apache config:

    <IfModule mod_python.c>
        AddHandler python-program py
        PythonPath "['/data/www/'] + sys.path"
        PythonDebug On
        PythonHandler blog
    </IfModule>

### Note, that blog.py is the module that contains the "handler"
function in the previous post.

Hope this helps (a bit more than before).

-Sean

> -----Original Message-----
> From: Sean Treadway [mailto:seant@superchannel.org]
> Sent: Thursday, July 01, 2004 10:29 AM
> To: 'Dave Wilson'; 'Gregory (Grisha) Trubetskoy'
> Cc: python-dev@httpd.apache.org
> Subject: RE: inital questions and patches
> 
> I ran across the following mod_python for pyblosxom.  Maybe this could
> be useful for your purposes:
> 
> #!/usr/local/bin/python
> from mod_python import apache, util
> import sys
> import config
> 
> __author__ = 'Wari Wahab <wari at wari.per.sg>'
> __version__ = config.py['pyblosxom_version']
> __date__ = "$Date: 2003/05/08 04:08:37 $"
> __revision__ = "$Revision: 1.9 $"
> __copyright__ = "Copyright (c) 2003 Wari Wahab"
> __license__ = "Python"
> 
> from Pyblosxom.pyblosxom import PyBlosxom
> from Pyblosxom.Request import Request
> 
> def handler(req):
>     req.content_type = 'text/html; charset=utf-8'
>     req.add_common_vars()
>     d = {}
>     for k, v in req.subprocess_env.items():
>         d[k] = v
>     config.py['stdoutput'] = req
>     config.py['renderer'] = 'modpython'
>     r = Request()
>     r.addConfiguration(config.py)
>     r.addHttp(d)
>     r.addHttp({'form':util.FieldStorage(req)})
>     p = PyBlosxom(r)
>     p.startup()
>     p.run()
>     return apache.OK
> 
> 
> 
> > -----Original Message-----
> > From: Dave Wilson [mailto:dave.lee.wilson@gmail.com]
> > Sent: Wednesday, June 30, 2004 7:18 PM
> > To: Gregory (Grisha) Trubetskoy
> > Cc: python-dev@httpd.apache.org
> > Subject: Re: inital questions and patches
> >
> > Gregory (Grisha) Trubetskoy <grisha@apache.org> wrote:
> > > Well, first of all, it is made pretty clear in the documentation
> that
> > the
> > > cgihandler is a hack.
> >
> > yep, understood.  unfortunately it seemed like it would be the best
> > way to use mod_python and pyblosxom, which relies on cgi only and is
> > ignorant of mod_python.  for example, I noticed the pyblosxom code
is
> > also inserting into sys.path on each request.  makes me think that
> > sys.path should be present itself as an ordered set, not allowing
dup
> > entries.
> >
> > > As to why it doesn't use execfile - I don't
> > > remember. Most likely it's because execfile will actually
interpret
> the
> > > source code from scratch every time, which is so slow, you might
as
> well
> > > not bother with mod_python at all and just use the Apache's CGI.
> >
> > so using load_module will compile it and keep it in memory?  can
> > execfile execute an already compiled .pyc?  would that too be slow?
> > any suggestions as to how I might set the __name__ variable when the
> > cgi script/module is loaded and run?  it's not necessary, just
> > curious.
> >
> > > Now this one I'm not so sure about. cgihandler will chdir into the
> > > directory of the script, and '.' should be in sys.path by default.
> >
> > it seems '.' is not in sys.path.  at least not at the time
> > cgihandler's code is executing.
> >
> > > Also, you cannot just insert things into sys.path because after
ten
> > > requests you'll end up with a sys.path that has ten dirs at the
> > beginning
> > > :-)
> >
> > yeah, I see now, thanks.  pyblosxom is doing the same thing.
> >
> > would anybody here like a gmail invite?  I only have one left.
> >
> > Dave
> 




Mime
View raw message