Hi Daniel,
Thank you so much for your suggestion. I am quite new to python and
twisted so I am not very certain about how to make it work well. Does that
mean if I change the dataReceived by adding a line to instantiate the
MultiEchoFactory like this, it will work?
def dataReceived(self, data):
"As soon as any data is received, write it back."
handlesendermessage = self.factory.app.handle_message(data)
if handlesendermessage:
self.transport.write(data)
MultiEchoFactory()
MultiEcho().dataReceived(data)
2015-04-29 0:33 GMT+08:00 Louis D. Burr <[email protected]>:
> Hi Jessica,
>
> On Apr 28, 2015, at 10:14 AM, Jessica Tsui <[email protected]> wrote:
>
> SNIP
>
> exceptions.AttributeError: MultiEcho instance has no attribute ‘factory'
>
> SNIP
>
> MultiEcho().dataReceived(sendermessage)
>
> Here you create an instance of the protocol directly, i.e., without having
> instantiated a MutilEchoFactory. The factory’s buildProtocol method is
> what assigns the factory instance as a member of the protocol
> (self.factory), and since you didn’t create the protocol via a factory, you
> have no factory attribute on your protocol instance.
>
> There are a number of ways to fix this, but generally speaking, you need
> to provide a way for your factories and their protocols to be aware of each
> other.
>
> Hope this helps,
>
> Daniel
> --
> L. Daniel Burr
> [email protected]
> (312) 656-8387
>
>
> _______________________________________________
> Twisted-Python mailing list
> [email protected]
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
_______________________________________________
Twisted-Python mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python