class ProxyIncomingProtocol(Protocol):<br>.....<br><br>class ProxyOutgoingProtocol(Protocol):<br>.....<br><br>class ProxyFactory(Factory):<br><br>    protocol = ProxyIncomingProtocol<br><br>class SimplePerspective(pb.Avatar):<br>
<br>    def perspective_echo(self, text):<br>        print &#39;echoing&#39;,text<br>        return text<br><br>    def logout(self):<br>        print self, &quot;logged out&quot;<br><br><br>class SimpleRealm:<br>    implements(IRealm)<br>
<br>    def requestAvatar(self, avatarId, mind, *interfaces):<br>        if pb.IPerspective in interfaces:<br>            avatar = SimplePerspective()<br>            return pb.IPerspective, avatar, avatar.logout<br>        else:<br>
            raise NotImplementedError(&quot;no interface&quot;)<br><br>portal = Portal(SimpleRealm())<br>checker = InMemoryUsernamePasswordDatabaseDontUse()<br>checker.addUser(&quot;guest&quot;, &quot;password&quot;)<br>portal.registerChecker(checker)<br>
<br><br>proxy_factory = proxy.ProxyFactory()<br># ??????? how can I add the portal to the factory?<br>internet.GenericServer(cometsession.Port, factory=proxy_factory, resource=root_resource, childName=&quot;tcp&quot;, interface=INTERFACE).setServiceParent(serviceCollection)<br>
<br><br>