[Twisted-Python] How to organize a web application?

Alexander May alex-news at comcast.net
Wed May 26 14:28:26 EDT 2004

I am looking for advice on how to organize a web application.  I've never
written a web application before, and would appreciate any insight into best
practices and overall structure.

I have html pages, html templates, an underlying database, and (hopefully)
an understanding of twisted and nevow.  What is the best way to glue all of
this together?

For example, what is the best way to associate derived rend.Page classes
with html templates?  I'll have all these different data and render
functions that could potentially be used by many different templates.  Do I
create one monster rend.Page derived class responsible for servicing all the
possible display an render functions?  That seems wrong.  What's the

What is the best way to manage links?  The html page template will link to
each other, mostly at the discretion of the html designers (admittedly me at
first).  Should I utilize the underlying file system to define the link
structure as I might do for static html site?  If yes, should I use
static.File and create a special resource type for the html template and
then return rend.Page derived classes?  Or should I do something else all

What is the best way to manage state (non database)?  Cookies or mugged URLS
mapped to closures seems like it would work well.  Perhaps someone has some
experience doing this?

I took a look at the Quotient source, and did not see any html templates at
all, so I assume all the html generation is occurring dynamically via Stan
or some other method.  Likewise for nevow Calendar example which has a
single html template and links to dynamically generated pages (I'll probably
need to do that too).

Thought and comments?


More information about the Twisted-Python mailing list