Mukhsein Johari wrote:
The thing is, I know I need to use twisted.web.resource but I'm not sure _how_. How does this fit in with the .rpy file? I think I need to create my modules and classes and then create an .rpy which acts as the erm..'interface' to the modules and classes. Could someone give me some hints and tips?
The model you're describing is just what Zope's ZPublisher and Quixote do. I would suggest using Zope, but if you feel it's too heavy then Quixote will likely be a perfect fit.
Another alternative, if you intend to use Twisted's other capabilities and thus want to use twisted.web, is something like this:
isLeaf = 1
def __init__(self, root): self.root = root
def render(self, request): obj = self.root for p in request.postpath: # convert "/foo/bar" to self.root.foo.bar obj = getattr(obj, p) if not callable(obj): return "arg" else: return obj(request)
Of course, this is probably insecure, buggy, and may not even work, but that's the general idea of how to do it.