[Twisted-Python] Twisted newb I can't add a cred checker to a Factory class
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Wed Jan 27 07:51:42 EST 2010
On 26 Jan, 09:40 pm, theiklabs at gmail.com wrote:
>class ProxyIncomingProtocol(Protocol):
>.....
>
>class ProxyOutgoingProtocol(Protocol):
>.....
>
>class ProxyFactory(Factory):
>
> protocol = ProxyIncomingProtocol
>
>class SimplePerspective(pb.Avatar):
>
> def perspective_echo(self, text):
> print 'echoing',text
> return text
>
> def logout(self):
> print self, "logged out"
>
>
>class SimpleRealm:
> implements(IRealm)
>
> def requestAvatar(self, avatarId, mind, *interfaces):
> if pb.IPerspective in interfaces:
> avatar = SimplePerspective()
> return pb.IPerspective, avatar, avatar.logout
> else:
> raise NotImplementedError("no interface")
>
>portal = Portal(SimpleRealm())
>checker = InMemoryUsernamePasswordDatabaseDontUse()
>checker.addUser("guest", "password")
>portal.registerChecker(checker)
>
>
>proxy_factory = proxy.ProxyFactory()
># ??????? how can I add the portal to the factory?
>internet.GenericServer(cometsession.Port, factory=proxy_factory,
>resource=root_resource, childName="tcp",
>interface=INTERFACE).setServiceParent(serviceCollection)
It doesn't make any sense to ask how to "add a portal to a factory".
Your protocol implementation needs to support twisted.cred. In the code
you included, I don't see any evidence of such support.
Also, with the unexplained mix of two "proxying" protocols (with their
implementations omitted), various classes from Twisted Spread (but not
enough to actually establish a PB connection as far as I can tell), and
something called "cometsession", it's hard to tell what you're actually
trying to accomplish, so I don't have any more specific suggestions to
make.
Jean-Paul
More information about the Twisted-Python
mailing list