[mod_python] Templaing question

Graham Dumpleton grahamd at dscpl.com.au
Sun Mar 5 16:16:34 EST 2006


Try clearing your browser cache. I've seen before that browsers are more
aggressive at caching stylesheets than other files. Thus it might be using
an older bogus file. Try renaming the stylesheet file and the reference to
it.

Also look in the Apache access_log/error_log to see if the server does in
fact receive a request to serve up the stylesheet.

Graham

Michael Guerrero wrote ..
> On Sun, 2006-03-05 at 14:13 -0500, Jim Gallacher wrote:
> 
> > marinus van aswegen wrote:
> > > Hi
> > > 
> > > I need some advice; I'm up the creek without a paddle. I wanted to
> quickly
> > > hack together a small project. I like python so, I thought hey lets
> try
> > > mod_python. I got some of the hard stuff sorted quickly e.g. login
> > > functions, session handling, etc. When it came to the presentation
> stuff I
> > > had a quick look at some of the templating toolkits out there, they
> scared
> > > me! I wanted something simple so I quickly hacked together a
> > > 
> > > simple templating system, that loaded my html files, replaced the tags
> I hid
> > > in them with the data I wanted send to the browser via req.write. The
> > > problem is that it renders the page in a weird way, kinda like it doesn't
> > > give the browser a chance to interpret the css. Where do I go from
> here, I
> > > want to give the client tables of data formatted with nice css.
> > > 
> > > Marinus
> > 
> > Hi Marinus,
> > 
> > It's not clear if you're asking for help with debugging your templating
> > system or advise on alternatives? I'd suggest taking another look at
> > mod_python.psp since it's included in mod_python, and people on this
> > list are familiar with it and more likely able to offer help.
> > 
> > Jim
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_py
> 
> I'm having the same issue as Marinus.
> 
> My codes looks like so:
> 
> -------------------------------------
> from mod_python import apache
> 
> def index(req):
>     req.content_type = 'text/html'
>     req.write(docType()) # a function which puts the doctype in the
> page.
>     req.write(head(title('Word List') + link('StyleSheet',
> 'index.css'))) # more functions to put the right tags in.
>     ...
>     ...
> ---------------------------------------
> 
> The page it creates looks like:
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> <head>
> <title>Word List</title>
> <link rel="StyleSheet" href="index.css" />
> 
> </head>
> <body>
> <h1 class="None">
> Welcome to Word List
> </h1>
> <p class="None">
> Please login or <a href="reg" name="register" title="register"
> class="None">
> register
> </a>
> 
> </p>
> <form action="auth" method="POST" class="None">
> <input type="text" name="name" value="" class="None" />
> <br /><input type="password" name="password" value="" class="None" />
> <input type="submit" name="submit" value="Login" class="None" />
> 
> </form>
> 
> </body>
> </html>
> ------------------------------------------------------------
> 
> The .css file is in the same directory as the index.py file, yet the
> browser won't render the page using the linked .css.
> 
> I have tried adding ../, ./, and the absolute path to the .css to no
> avail.  When I save the source of the page, and then open it with my
> browser it links to the .css properly.
> 
> Any help would be much appreciated.
> 
> Regards,
> 
> Michael C. Guerrero


More information about the Mod_python mailing list