~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/upgrades/2.0/components.html

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html  PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'  'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html lang="en" xmlns="http://www.w3.org/1999/xhtml">
 
2
  <head>
 
3
<title>Twisted Documentation: The Twisted Zope Interfaces FAQ</title>
 
4
<link href="../../howto/stylesheet.css" rel="stylesheet" type="text/css"/>
 
5
  </head>
 
6
 
 
7
  <body bgcolor="white">
 
8
    <h1 class="title">The Twisted Zope Interfaces FAQ</h1>
 
9
    <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 did Twisted switch to Zope Interfaces?</a></li><li><a href="#auto3">Why did Twisted switch 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">
 
10
 
 
11
What about third party classes dependant on the old style of implements
 
12
declarations?
 
13
 
 
14
</a></li><li><a href="#auto7">What about using third party classes?</a></li></ul><li><a href="#auto8">Acknowledgements</a></li></ol></div>
 
15
    <div class="content">
 
16
 
 
17
<span/>
 
18
 
 
19
<h2>Twisted components system in 2.0<a name="auto0"/></h2>
 
20
 
 
21
<p>Twisted code's own use of the <code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.python.components.html" title="twisted.python.components">twisted.python.components</a></code> package has been updated to use <a href="http://www.zope.org/Wikis/Interfaces/FrontPage" shape="rect">Zope Interfaces</a> in
 
22
the 2.0 release.</p>
 
23
 
 
24
<p>New code developed starting with the 2.0 release of Twisted Core should use Zope
 
25
Interfaces directly rather than using the twisted.python.components
 
26
package.</p>
 
27
 
 
28
<h2>FAQ<a name="auto1"/></h2>
 
29
 
 
30
<h3>Why did Twisted switch to Zope Interfaces?<a name="auto2"/></h3>
 
31
 
 
32
<p>
 
33
The twisted.python.components package is a large amount of on-going
 
34
maintenance. Using the Zope Interface package also provides a greater level of
 
35
compatibility between Twisted interfaces and Zope interfaces.
 
36
</p>
 
37
 
 
38
<h3>Why did Twisted switch to Zope Interfaces rather than PyProtocols?<a name="auto3"/></h3>
 
39
 
 
40
<p>
 
41
The Zope Interface package was chosen over PyProtocols because of its greater
 
42
conceptual similarity to twisted.python.components.
 
43
</p>
 
44
 
 
45
<h3>Will this affect my deployment?<a name="auto4"/></h3>
 
46
 
 
47
<p>
 
48
No. Releases of Twisted Core will include Zope Interfaces.
 
49
</p>
 
50
 
 
51
<h3>How can I update my own code?<a name="auto5"/></h3>
 
52
 
 
53
<p>
 
54
Classes written using twisted.python.components declare which interfaces they
 
55
implement in this style:
 
56
</p>
 
57
 
 
58
<code>
 
59
class C:
 
60
    __implements__ = IFoo,
 
61
</code>
 
62
 
 
63
<p>
 
64
This should be changed to:
 
65
</p>
 
66
 
 
67
<code>
 
68
class C:
 
69
    zope.interface.implements(IFoo)
 
70
</code>
 
71
 
 
72
<h3>
 
73
 
 
74
What about third party classes dependant on the old style of implements
 
75
declarations?
 
76
 
 
77
<a name="auto6"/></h3>
 
78
 
 
79
<p>
 
80
Use <code class="API"><a href="http://twistedmatrix.com/documents/10.0.0/api/twisted.python.components.backwardsCompatImplements.html" title="twisted.python.components.backwardsCompatImplements">backwardsCompatImplements</a></code> to fix this.
 
81
</p>
 
82
 
 
83
<code>
 
84
twisted.python.components.backwardsCompatImplements(C)
 
85
</code>
 
86
 
 
87
<h3>What about using third party classes?<a name="auto7"/></h3>
 
88
 
 
89
<p>
 
90
If you are using third party libraries that only declare __implements__, these
 
91
objects should be made compatible with <code base="twisted.python.components">fixClassImplements</code>: </p>
 
92
 
 
93
<code>
 
94
# import o where o is some third party library
 
95
from thirdparty.lib import o
 
96
 
 
97
twisted.python.components.fixClassImplements(o.__class__)
 
98
</code>
 
99
 
 
100
<p>
 
101
This will make sure that __implements__ declarations get converted to the new
 
102
style of implements declarations.
 
103
</p>
 
104
 
 
105
<h2>Acknowledgements<a name="auto8"/></h2>
 
106
 
 
107
<p>This document is the work of Jason A. Mobarak, with contributions from Mary
 
108
Gardiner.</p>
 
109
 
 
110
</div>
 
111
 
 
112
    <p><a href="../../howto/index.html">Index</a></p>
 
113
    <span class="version">Version: 10.0.0</span>
 
114
  </body>
 
115
</html>
 
 
b'\\ No newline at end of file'