[Twisted-Python] Linking between twisted.web resources.
carmstro at dynup.net
Sun Mar 4 13:12:33 EST 2001
I've come to the conclusion that linking in twisted.web is way too complicated.
Here's an idea: how about keeping track of certain resource's paths so
resources under it can link back to it?
I just typed the following code as I wrote the email, so there are probably
minor bugs, but you should get the idea.
registerPath() #imaginary function
def render(self, request):
return self.webpage(request, 'MySite',
Hi there! welcome to my neato site!<br>
<a href="FooBar">Go here!</a>
def render(self, request)
return self.webpage(request, 'FooBar',
Hi! This is FooBar. Would you like to go back to my
<a href="%s">Main Site?</a>
''' % LinkMe('MySite')
So, we have registerPath() and LinkMe(). I'm sure it won't be
as simple as this, but I do think it should be possible. The main problem
we have is handling multiple instances of MySite. During instantiation of
MySite, when registerPath() is called, some external data source will be
updated with MySite, the path that it's instantiated to, and some sort of
ID. Then, somehow, when we want to link to this, we use the LinkMe function.
The paramaters will probably need to be the ID and the name of the resource.
With this LinkMe design, Resources of completely unrelated sections of
the site (ie, resources not under MySite) will be able to link to it
without even knowing the path.
I know there are many many holes in this idea (for instance, how will resources
that want to LinkMe get the ID of the resources to be linked to?), but I
really think something like this is needed. Any thoughts?
Chris Armstrong http://twistedmatrix.com/~carmstro carmstro at dynup.net
There is a 90% chance that this message was written when the author's been
awake longer than he should have. Please disregard any senseless drivel.
More information about the Twisted-Python