On 05:37 pm, [email protected] wrote:
>D'oh!
>That's what happens when you copy code from the web, sorry :-(
>
>So just a follow up to my other question: how do I add my child
>resources?
>Does my TestRealm need to extend Resource? Is that the recommended
>approach?
Your TestRealm is responsible for giving out avatars, in this case
IResource implementations. If you want to add child resources, they
need to be added to the IResource implementation that TestRealm is going
to give out. I don't remember if you gave the implementation of
TestRealm anywhere in this thread already, but take this simple
imaginary version:
class User(Resource):
def __init__(self):
Resource.__init__(self)
self.addChild("innocuous", InnocuousResource())
class Administrator(User):
def __init__(self):
User.__init__(self) self.addChild("sensitive",
SensitiveResource())
class TestRealmobject):
...
def requestAvatar(self, avatarId, mind, *interfaces):
...
if self.isAdministrator(avatarId):
avatar = Administrator()
else:
avatar = User()
return IResource, avatar, logout
Put another way, the resources given out by TestRealm are just
resources. Treat them as you would treat any other resources.
Jean-Paul
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web