[Twisted-Python] policies.py change in 2.0

Brian Kirsch bkirsch at osafoundation.org
Fri Apr 15 15:36:29 EDT 2005

Hey guys,
Question for you. In the 2.0 Twisted release the 
policies.ProtocolWrapper changed on line 31 to now set the 
wrappedProtocol.factory to point to the wrappingFactory.

  def __init__(self, factory, wrappedProtocol):
        self.wrappedProtocol = wrappedProtocol
<      self.factory = factory
 >      self.factory = wrappedProtocol.factory = factory

 I was wondering what the reason for the change was? The change caused 
our current code to break (an easy fix). It seems to me that the wrapper 
should be transparent to the wrappedProtocol. Changing the protocol's 
factory leads to unexpected behavior if that protocol is depending on 
specific methods or data in the  factory. In fact this change actually 
breaks the Twisted smtp.py code.

   def getMailFrom(self):
        if not self.done:
            self.done = 1
          /  return str(self.factory.fromEmail) #this will now break if 
            return None

Brian Kirsch - Email Framework Engineer
Open Source Applications Foundation
543 Howard St. 5th Floor
San Francisco, CA 94105
(415) 946-3056

More information about the Twisted-Python mailing list