[mod_python] Announcement: Roadkill version 0.01 "Kitten"

Gre7g Luterman gre7g-k-modpython.e475ec at wolfhome.com
Sun Jun 8 11:24:33 EST 2003

> - - Permanent and temporary sessions. Every website uses cookies for
> only one thing - sessions. We should have this built in by default.

Personally, I prefer to pass a variable SID around with each link and 
form.  Yeah, it's not as convenient as a cookie, but at least you 
don't have to worry about cookies being enabled.  Plus, it is 
available on the first page load and it is compatible with CGI's I 
wrote before getting into mod_python, where it was too tricky to 
modify headers to set one.

> - - Keeping HTML totall separate from the code is a very good idea.
> Unfortunately, it makes things like loops or iterations (like listing
> some results) difficult. I believe the best way around this is to
> allow some python code, in its pure python form, in the page somehow.
> However, this should be extremely light and only when necessary. Is
> there anyway around this? 

When I code with templates, I use the following syntax in my HTML to 
bury loops:

<!-- var: BlockName --> ( text to be repeated ) <!-- /var -->

My template class can also handle <!-- /var (VarName) --> which 
doesn't affect operation, but it can make the HTML easier to decypher 
when you stack these.

I embed variables in the traditional way:


And then to do the loop in Python, I do something like:

Block = T["BlockName"]
while Condition:
  T["VarName"] = "value"

print T

To conditionally remove a block:

if Condition:

Lastly, I bury constants in my HTML with:

<!-- var: VarName="value" -->

And access it with:

VarName = T["VarName"]

Of course, none of this is ground breaking.  I'm sure a million 
programmers have made a similar tool as well.  However, if anyone 
would like a copy of my class, just drop me a note.

I thought about putting it up as a project on SourceForge, but after 
embarassing myself so with RoadKill since I didn't realize spyce 
existed, I'm a tad hesitant.


Gre7g Luterman   gre7g at wolfhome.com  http://www.templeofluna.com/
Stay informed: http://www.templeofluna.com/keeper/mailinglist.htm

        I want to die peacefully in my sleep, like my grandfather
                  ...not screaming in terror like his passengers.

More information about the Mod_python mailing list