<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 2 Jul 2009, at 23:50, Mikhail wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>In my example I should have written <br><br> &nbsp;&nbsp;&nbsp;run(application)<br><br>instead of <br><br> &nbsp;&nbsp;&nbsp;run(...)<br><br>Then the difference would be more apparent. Namely, in my 'wrapper'<br>it is explicit what application will be run and where all the services<br>came from, your 'wrapper' is just a customized version of twistd and <br>what will be run depends on the command line and what will be found <br>in the file system. In some cases I'd like to _explicitly_ code into <br>main script what functionality my application provides and I do not<br>want twistd search file system for plugins at all.<font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><br></div><div>I'm&nbsp;not&nbsp;using&nbsp;plugins,&nbsp;but&nbsp;I&nbsp;had&nbsp;the&nbsp;same&nbsp;requirement&nbsp;as&nbsp;you&nbsp;to&nbsp;explicitly&nbsp;create&nbsp;the&nbsp;app&nbsp;and&nbsp;then&nbsp;run&nbsp;it&nbsp;-&nbsp;because&nbsp;I&nbsp;need&nbsp;the&nbsp;freeze&nbsp;scripts&nbsp;to&nbsp;make&nbsp;a&nbsp;single&nbsp;application.</div><div><br></div><div>My&nbsp;solution&nbsp;looked&nbsp;something&nbsp;like:</div><div><br></div><div># myapp.py</div><div><br></div><div>from twisted.scripts._twistd_unix import UnixApplicationRunner</div><div># Of course, that's just because the app is unix only</div><div><br></div><div><br></div><div>class MyRunner(UnixApplicationRunner):</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>def createOrGetApplication(self):</div><div><span class="Apple-tab-span" style="white-space:pre">                </span># The stuff that's usually in a tac file</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>application = # ...</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>return application</div><div><br></div><div>def main():</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>setup_logging()</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>config = { # stuff pinched by dumping 'config' during a twistd run</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">        </span># Also do the ServerOptions thing here if necessary</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>MyRunner(config).run()</div><div><br></div><div>if __name__ == '__main__'</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>main()</div><div><br></div><div><br></div><div><br></div></body></html>