<?xml version="1.0"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><title>Twisted Documentation: The Twisted Zope Interfaces FAQ</title><link href="../../howto/stylesheet.css" type="text/css" rel="stylesheet" /></head><body bgcolor="white"><h1 class="title">The Twisted Zope Interfaces FAQ</h1><div class="toc"><ol><li><a href="#auto0">Twisted components system in 2.0</a></li><li><a href="#auto1">FAQ</a></li><ul><li><a href="#auto2">Why is Twisted switching to Zope Interfaces?</a></li><li><a href="#auto3">Why is Twisted switching to Zope Interfaces rather than PyProtocols?</a></li><li><a href="#auto4">Will this affect my deployment?</a></li><li><a href="#auto5">How can I update my own code?</a></li><li><a href="#auto6"> What about third party classes dependant on the old style of implements declarations? </a></li><li><a href="#auto7">What about using third party classes?</a></li></ul><li><a href="#auto8">Acknowledgements</a></li></ol></div><div class="content"><span></span><h2>Twisted components system in 2.0<a name="auto0"></a></h2><p>Twisted code's own use of the <code class="API">twisted.python.components</code> package has been updated to use <a href="http://www.zope.org/Wikis/Interfaces/FrontPage">Zope Interfaces</a> in the 2.0 release.</p><p>New code developed using the 2.0 release of Twisted Core should use Zope Interfaces directly rather than using the twisted.python.components package.</p><h2>FAQ<a name="auto1"></a></h2><h3>Why is Twisted switching to Zope Interfaces?<a name="auto2"></a></h3><p> The twisted.python.components package is a large amount of on-going maintainence. Using the Zope Interface package also provides a greater level of compatibility between Twisted interfaces and Zope interfaces. </p><h3>Why is Twisted switching to Zope Interfaces rather than PyProtocols?<a name="auto3"></a></h3><p> The Zope Interface package was chosen over PyProtocols because of its greater conceptual similarity to twisted.python.components. </p><h3>Will this affect my deployment?<a name="auto4"></a></h3><p> No. Releases of Twisted Core will include Zope Interfaces. </p><h3>How can I update my own code?<a name="auto5"></a></h3><p> Classes written using twisted.python.components declare which interfaces they implement in this style: </p><code> class C: __implements__ = IFoo, </code><p> This should be changed to: </p><code> class C: zope.interface.implements(IFoo) </code><h3> What about third party classes dependant on the old style of implements declarations? <a name="auto6"></a></h3><p> Use <code base="twisted.python.components" class="API">backwardsCompatImplements</code> to fix this. </p><code> twisted.python.components.backwardsCompatImplements(C) </code><h3>What about using third party classes?<a name="auto7"></a></h3><p> If you are using third party libraries that only declare __implements__, these objects should be made compatible with <code base="twisted.python.components">fixClassImplements</code>: </p><code> # import o where o is some third party library from thirdparty.lib import o twisted.python.components.fixClassImplements(o.__class__) </code><p> This will make sure that __implements__ declarations get converted to the new style of implements declarations. </p><h2>Acknowledgements<a name="auto8"></a></h2><p>This document is the work of Jason A. Mobarak, with contributions from Mary Gardiner.</p><!-- <h3>Will my code break?</h3> <p> No. Please see insert slyphon's z.i tutorial </p> Stuff below may be redundant if slyphon has finished his tutorial. Otherwise it might be a good idea for me to finish? --><!-- However, there are some differences between t.p.c and Zope interfaces. Classes originally written in this manner: <code> class C: __implements__ = IFoo, </code> Should be changed to: <code> class C: zope.interface.implements(IFoo) </code> <h3> What about third party classes dependant on the old style of implements declarations? </h3> From twisted.python.components, backwardsCompatImplements will fix this, for example: <code> twisted.python.components.backwardsCompatImplements(C) </code> </p> <h3>What about using third party classes?</h3> <p> If you are using third party libraries that only declare __implements__, these objects should be made compatible with fixClassImplements from twisted.python.components, for example: <code> twisted.python.componets.fixClassImplements(o.__class__) </code> This will make sure that __implements__ declarations get converted to the new style of implements declarations. </p> <h3>Where can I get Zope Interfaces</h3> <p> Individually packaged release can be found from the <a href="http://zope.org/Products/ZopeInterface/">Zope Interface</a> project website. Releases of <a href="splitfaq">Twiste-core</a> will also include the Zope Interface package. </p> --></div><p><a href="../../howto/index.html">Index</a></p><span class="version">Version: 2.5.0</span></body></html>