[Twisted-Python] Fear and Loathing in Twisted Web and Woven

Alex Levy mesozoic at polynode.com
Tue Jul 15 09:47:05 MDT 2003


I have a specific question and a more general plea for help here, in that
order:

1) I'd like to set certain configuration elements of my site (like "site name",
"template directory", etc.) within my root .rpy, then read them in my Page
classes, wmfactory_* methods, and so forth. Donovan suggested I look at the
registry or the request.site objects, and that advice is as far as I've
gotten.

The registry, as far as I can tell, is not passed to child objects returned
by static.File.getChild. So I'm not sure how I could access that from
within my own classes.

The request, on the other hand, is not accessible from the .rpy. I've tried
registry.getComponent(server.Site) and registry.getComponent(server.Request)
and they both return None. So I'm lost.

Am I simply taking the wrong approach (again) to what I'm trying to do? My
current workaround is to put 'child.registry=self.registry' in
static.File.getChild, before it returns child, but this is a kludge and I
know it.

2) In general, I'm not sure how to write my app anymore, and could use some
help. If you have a minute to read, here's a more about what I'm doing:

I've been using .trp files to store my data, and some have asked me why. I
have complicated data that represents pages on my site. Photo albums, link
collections, etc. I would like to store this data as part of a flat file
hierarchy, so that it resides alongside .html, .stxt, .jpg, and so forth.

I also didn't want to pickle my models; this has caused problems in the
past. So I have Data classes, which are adapted to IModel and IResource with
my custom Model and Page classes (respectively). I store the data files as
.trp, and when somebody navigates to /foo/bar.trp, whichever adapter I've
specified in code is automatically used. I like this; it avoids having to
write static.File processors, which are in my opinion ugly (and not very
scalable).

I am open to suggestions and comments. My goal is to have a flexible code
base on top of which I can expand my personal page, while keeping everything
within a single directory. If this is a pipe dream, and I should be writing
PhotoAlbumContainers and creating them in my root .rpy and moving my links
around so that static files and dynamic pages are hierarchically separated,
somebody tell me (and tell me why).

I really am looking for guidance on this; my first Twisted app (which
currently powers my web page) is a kludgy nasty hack, and I want to make
this ultra-refactoring as clean and "pure" as possible.

-- 
Alex Levy
WWW: http://mesozoic.geecs.org
 
"Never let your sense of morals prevent you from doing what is right."
 -- Salvor Hardin, Isaac Asimov's _Foundation_




More information about the Twisted-Python mailing list