Project: Twisted
Revision: 24673
Author: therve
Date: 02 Sep 2008 11:51:38
Diff at Trac: http://twistedmatrix.com/trac/changeset/24673
Changes:Remove tap support, clean API links.
Files:modified: /branches/run-plugin-1490-2/twisted/names/tap.py (
try)
modified: /branches/run-plugin-1490-2/twisted/plugins/twisted_run.py (
try)
modified: /branches/run-plugin-1490-2/twisted/test/test_twistd.py (
try)
modified: /branches/run-plugin-1490-2/twisted/conch/tap.py (
try)
modified: /branches/run-plugin-1490-2/twisted/web/tap.py (
try)
modified: /branches/run-plugin-1490-2/doc/core/howto/tap.xhtml (
try)
modified: /branches/run-plugin-1490-2/twisted/mail/tap.py (
try)
Diff:
| ... | ...@@ -7,8 +7,6 @@ |
| 7 | 7 | |
| 8 | 8 | import os, traceback |
| 9 | 9 | |
| 10 | | from zope.interface import moduleProvides |
| 11 | | |
| 12 | 10 | from twisted.python import usage |
| 13 | 11 | from twisted.names import dns |
| 14 | 12 | from twisted.application import internet, service |
| ... | ...@@ -18,8 +16,6 @@ |
| 18 | 16 | from twisted.names import secondary |
| 19 | 17 | |
| 20 | 18 | |
| 21 | | moduleProvides(service.ISimpleServiceMaker) |
| 22 | | |
| 23 | 19 | |
| 24 | 20 | class Options(usage.Options): |
| 25 | 21 | optParameters = [ |
| ... | ...@@ -77,12 +77,7 @@ |
| 77 | 77 | if not ISimpleServiceMaker.providedBy(maker): |
| 78 | 78 | raise SystemExit("'%s' doesn't provide the ISimpleServiceMaker " |
| 79 | 79 | "interface" % (options['maker'],)) |
| 80 | | opts = getattr(maker, 'options', None) |
| 81 | | if opts is not None: |
| 82 | | subOptions = opts() |
| 83 | | else: |
| 84 | | # Compatibility with tap module |
| 85 | | subOptions = maker.Options() |
| 80 | subOptions = maker.options() |
| 86 | 81 | subOptions.parseOptions(options['maker_options']) |
| 87 | 82 | return maker.makeService(subOptions) |
| 88 | 83 | |
| ... | ...@@ -1077,30 +1077,10 @@ |
| 1077 | 1077 | |
| 1078 | 1078 | |
| 1079 | 1079 | |
| 1080 | | class StubTAP(object): |
| 1081 | | """ |
| 1082 | | A fake TAP module to be run by L{RunPlugin}. |
| 1083 | | """ |
| 1084 | | implements(service.ISimpleServiceMaker) |
| 1085 | | Options = StubOptions |
| 1086 | | |
| 1087 | | def makeService(self, options): |
| 1088 | | """ |
| 1089 | | Create a dummy service and save options in C{self.savedOptions}. |
| 1090 | | """ |
| 1091 | | self.savedOptions = options |
| 1092 | | self.service = service.Service() |
| 1093 | | return self.service |
| 1094 | | |
| 1095 | | |
| 1096 | | |
| 1097 | 1080 | class RunPluginTests(unittest.TestCase): |
| 1098 | 1081 | """ |
| 1099 | 1082 | Tests for the twistd L{RunPlugin}. |
| 1100 | 1083 | |
| 1101 | | @cvar stubTAP: a TAP module to use during tests. |
| 1102 | | @type stubTAP: L{StubTAP} |
| 1103 | | |
| 1104 | 1084 | @cvar stubService: a service to use during tests. |
| 1105 | 1085 | @type stubService: L{StubServiceMaker} |
| 1106 | 1086 | |
| ... | ...@@ -1114,7 +1094,6 @@ |
| 1114 | 1094 | def setUp(self): |
| 1115 | 1095 | self.plugin = RunPlugin() |
| 1116 | 1096 | cls = self.__class__ |
| 1117 | | cls.stubTAP = StubTAP() |
| 1118 | 1097 | cls.stubService = StubServiceMaker() |
| 1119 | 1098 | directlyProvides(cls.stubService, service.ISimpleServiceMaker) |
| 1120 | 1099 | self.serviceName = "%s.%s.stubService" % ( |
| ... | ...@@ -1126,7 +1105,6 @@ |
| 1126 | 1105 | Cleanup class variables. |
| 1127 | 1106 | """ |
| 1128 | 1107 | cls = self.__class__ |
| 1129 | | cls.stubTAP = None |
| 1130 | 1108 | cls.stubService = None |
| 1131 | 1109 | |
| 1132 | 1110 | |
| ... | ...@@ -1220,19 +1198,6 @@ |
| 1220 | 1198 | self.assertRaises(usage.UsageError, self.plugin.makeService, opt) |
| 1221 | 1199 | |
| 1222 | 1200 | |
| 1223 | | def test_tapModule(self): |
| 1224 | | """ |
| 1225 | | L{RunPlugin.makeService} supports running TAP modules, the difference |
| 1226 | | being that the options attribute has a different name. |
| 1227 | | """ |
| 1228 | | opt = self.plugin.options() |
| 1229 | | opt.parseArgs("%s.%s.stubTAP" % ( |
| 1230 | | self.__module__, self.__class__.__name__)) |
| 1231 | | srv = self.plugin.makeService(opt) |
| 1232 | | self.assertIdentical(srv, self.stubTAP.service) |
| 1233 | | self.assertEquals(self.stubTAP.savedOptions, {'foo': '1234'}) |
| 1234 | | |
| 1235 | | |
| 1236 | 1201 | def test_foundInPlugins(self): |
| 1237 | 1202 | """ |
| 1238 | 1203 | L{plugin.getPlugins} should return L{RunPlugin} as a potential |
| ... | ...@@ -5,18 +5,11 @@ |
| 5 | 5 | Support module for making SSH servers with mktap. |
| 6 | 6 | """ |
| 7 | 7 | |
| 8 | | from zope.interface import moduleProvides |
| 9 | | |
| 10 | 8 | from twisted.conch import checkers, unix |
| 11 | 9 | from twisted.conch.openssh_compat import factory |
| 12 | 10 | from twisted.cred import portal |
| 13 | 11 | from twisted.python import usage |
| 14 | 12 | from twisted.application import strports |
| 15 | | from twisted.application.service import ISimpleServiceMaker |
| 16 | | |
| 17 | | |
| 18 | | |
| 19 | | moduleProvides(ISimpleServiceMaker) |
| 20 | 13 | |
| 21 | 14 | |
| 22 | 15 | |
| ... | ...@@ -7,8 +7,6 @@ |
| 7 | 7 | |
| 8 | 8 | import os |
| 9 | 9 | |
| 10 | | from zope.interface import moduleProvides |
| 11 | | |
| 12 | 10 | from twisted.web import server, static, twcgi, script, demo, distrib, trp |
| 13 | 11 | from twisted.internet import interfaces |
| 14 | 12 | from twisted.python import usage, reflect |
| ... | ...@@ -17,10 +15,6 @@ |
| 17 | 15 | |
| 18 | 16 | |
| 19 | 17 | |
| 20 | | moduleProvides(service.ISimpleServiceMaker) |
| 21 | | |
| 22 | | |
| 23 | | |
| 24 | 18 | class Options(usage.Options): |
| 25 | 19 | synopsis = "Usage: mktap web [options]" |
| 26 | 20 | optParameters = [["port", "p", "8080","Port to start the server on."], |
| ... | ...@@ -136,10 +136,11 @@ |
| 136 | 136 | </code>. <code class="python">makeService</code> is to return the <code |
| 137 | 137 | class="API" base="twisted.application.service">IService</code> |
| 138 | 138 | implementation which will be run by <code class="shell">twistd</code>, |
| 139 | | in this case an <code class="API" base="twisted.application"> |
| 140 | | internet.TCPServer</code>. You can read more about services in the <a |
| 141 | | href="application.xhtml">application howto</a>: for example, it describes |
| 142 | | <a href="application.xhtml#services-provided">the list of services |
| 139 | in this case an |
| 140 | <code class="API" base="twisted.application">internet.TCPServer</code>. You |
| 141 | can read more about services in the <a href="application.xhtml">application |
| 142 | howto</a>: for example, it describes <a |
| 143 | href="application.xhtml#services-provided">the list of services |
| 143 | 144 | provided</a> and how to build <a |
| 144 | 145 | href="application.xhtml#service-collection">service collections</a>. |
| 145 | 146 | </p> |
| ... | ...@@ -147,15 +148,15 @@ |
| 147 | 148 | Note that you need to create an instance of |
| 148 | 149 | <code class="python">MyServiceMaker</code> because <code class="shell"> |
| 149 | 150 | twistd run</code> accepts the name of an object that <strong>provides |
| 150 | | </strong> <code class="API" base="twisted.application.service"> |
| 151 | | ISimpleServiceMaker</code>, not the name of an object that <strong> |
| 152 | | implements</strong> it. |
| 151 | </strong> |
| 152 | <code class="API" base="twisted.application.service">ISimpleServiceMaker</code>, |
| 153 | not the name of an object that <strong> implements</strong> it. |
| 153 | 154 | </p> |
| 154 | 155 | |
| 155 | 156 | <p> |
| 156 | 157 | To run this service, you call the run plugin with twistd, passing the fully |
| 157 | | qualified named of your object providing <code class="API" base="twisted.application.service"> |
| 158 | | ISimpleServiceMaker</code>. |
| 158 | qualified named of your object providing |
| 159 | <code class="API" base="twisted.application.service">ISimpleServiceMaker</code>. |
| 159 | 160 | </p> |
| 160 | 161 | |
| 161 | 162 | <pre class="shell"> |
| ... | ...@@ -8,8 +8,6 @@ |
| 8 | 8 | |
| 9 | 9 | import os |
| 10 | 10 | |
| 11 | | from zope.interface import moduleProvides |
| 12 | | |
| 13 | 11 | from twisted.mail import mail |
| 14 | 12 | from twisted.mail import maildir |
| 15 | 13 | from twisted.mail import relay |
| ... | ...@@ -20,11 +18,6 @@ |
| 20 | 18 | |
| 21 | 19 | from twisted.cred import checkers |
| 22 | 20 | from twisted.application import internet |
| 23 | | from twisted.application.service import ISimpleServiceMaker |
| 24 | | |
| 25 | | |
| 26 | | |
| 27 | | moduleProvides(ISimpleServiceMaker) |
| 28 | 21 | |
| 29 | 22 | |
| 30 | 23 | |
To list