[mod_python] Templaing question

Michael Guerrero m at mguerrero.net
Sun Mar 5 11:32:44 EST 2006


On Sun, 2006-03-05 at 16:24 -0500, Graham Dumpleton wrote:

> BTW, you are using "index" for name of function suggesting you are
> using publisher. If you are using publisher, are you using SetHandler
> or AddHandler?
> 
> If you use SetHandler so that all requests to the directory go through
> publisher, it will mean that your stylesheet request will also go through
> publisher. It will not be able to satisfy the request and will return not
> found. Browsers tend to ignore not found errors on stylesheets and
> do not show an error.
> 
> Thus, if you must use SetHandler, include in your configuration:
> 
>   <Files *.css>
>   SetHandler default-handler
>   </Files>
> 
> Graham
> 
> Graham Dumpleton wrote ..
> > 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
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> 


Oh yea, one more Apache Newb question.

Should I put the Files *.css directive in my python.conf file or in my
http.conf file?  Or does it matter which?

Regards,

Michael C. Guerrero
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060305/48ebd224/attachment-0001.html


More information about the Mod_python mailing list