[Twisted-Python] db connections
    Enrique Samson Jr. 
    enriquejr at gmail.com
       
    Fri Mar 27 19:32:54 MDT 2009
    
    
  
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.
HTH,
Enrique
    
    
More information about the Twisted-Python
mailing list