[Twisted-Python] Accessing app-wide data in Woven

mesozoic mesozoic at polynode.com
Fri Jul 18 10:44:22 MDT 2003


I am writing a Woven app that I would like to make fairly configurable by
the end-user without asking them to change my code. The way I'm doing this
now is with a special class, SiteConfiguration, that is given various data
in the root-level .rpy.

Now, every Page, every Model, and every View should (in my perfect world) be
able to get at this class. There should be only one SiteConfiguration; I'd
like to avoid calling it "global", because I know that word means many
different things. So what I do in my .rpy is:

 cfg = SiteConfiguration(...)
 registry.setComponent(SiteConfiguration, cfg)
 
Then, my site's static.File class sets 'child.registry = self.registry' and
'child.model.registry = self.registry' on everything it returns from
getChild. My Model classes then do some funkiness to find their top-level
parent and get the registry from that; I imagine my Pages could do the same.

But this seems a bit kludgish to me; I'm wondering if there is a more
general way of doing this that would not involve changing the behavior of
static.File.getChild.

Ideas?

-- 
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