[Twisted-Python] db connections

Pet petshmidt at googlemail.com
Sat Mar 28 02:35:05 MDT 2009


On Sat, Mar 28, 2009 at 2:32 AM, Enrique Samson Jr. <enriquejr at gmail.com> wrote:
> On Wed, 2009-03-25 at 11:00 +0100, Pet wrote:
>> > Hi,
>> >
>> > thanks for example!
>> > In that way, I'm getting error:
>> >
>> > exceptions.AttributeError: MyProtocol instance has no attribute 'factory'
>> >
>> > How can MyProtocol access self.factory.dbcon?
>>
>> Ups! I didn't followed exactly your example and tried to access
>> self.factory.dbcon in __init__ of MyProtocol, so I've got an error.
>> If I access self.factory.dbcon in lineReceived it seems to work. But I
>> don't really understand, why can I access factory in lineReceived and
>> not in __init__.
>>
>> Pet
>
> Hi Pet,
>
> You can simply look into the buildProtocol code of Factory for an
> explanation. This is the part where your protocol gets to be
> instantiated.

thanks for a hint. I'll look into that closer. Twisted is like a black
box for me right now. However, I've managed to write a useful
Client-Server App :)

>
>
> HTH,
>
> Enrique
>
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>




More information about the Twisted-Python mailing list