Warning: リポジトリと同期できません (サポートされていないバージョンコントロールシステム "svn です。 Python のライブラリに "svn" が正しくインストールされているか確認してください。)

バージョン 1 から バージョン 2 における更新: TracDoc/BasicEggCookingJa

差分発生行の前後
無視リスト:
更新日時:
2006/04/23 11:39:13 (18 年 前)
更新者:
weekbuild (IP アドレス: 59.147.202.119)
コメント:

--

凡例:

変更なし
追加
削除
変更
  • TracDoc/BasicEggCookingJa

    v1 v2  
    11{{{ 
    22#!trachtml 
    3 <h1 id="Egg cooking">Egg cooking</h1><br /> [http://trac-hacks.org/wiki/EggCookingTutorial/BasicEggCooking 原文]     <br /> <br />  <p><strike>Since Trac 0.9 it has been possible to write plugins for Trac to extend Trac functionality. Even better, you can deploy plugins as [http://peak.telecommunity.com/DevCenter/PythonEggs Python eggs]        that really makes plugin development fun and easy.</strike> </p><p>こ のチュートリアルはeggを作る方法とeggをTracにロードする方法を示します。なお、Advanced Partsで、テンプレートや静的コンテンツをeggから提 供する方法を学ぶ。 This tutorial shows how to make an egg, and load an egg in Trac. In the advanced parts you'll learn how to serve templates and static content from an egg. </p><p><strike>You should be familiar with [trac:TracDev/ComponentArchitecture component architecture]        and [trac:TracDev/PluginDevelopment plugin development]       . This plugin is based on the example in the plugin development article. <em>Here we extend it a bit further.</em></strike></p> <p>あなたは、[http://projects.edgewall.com/trac/wiki/TracDev/ComponentArchitecture component architecture]       や [wiki:TracDoc/PluginDevelopmentJa plugin development]       も見ておくべき。今回のプラグインはplugin developmentの記事の例に基づいている。ここでは、それにちょっと深入りするけど。 </p> <h2 id="Required items (必要なもの) ">Required items (必要なもの) </h2> <p><strike>First you need <em>setuptools</em>. For instructions and files see [http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install EasyInstall]        page. </strike></p><p><strike>You also need Trac 0.9.  Download it from the [trac:TracDownload#LatestDevelopmentRelease0.9beta2 TracDownload]        page.</strike><br /> </p> <p>まず、setuptoolsが必要。[http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install EasyInstall]      を参照。<br /> Trac0.9も必要。<br />  </p> <h2 id="Directories">Directories</h2> <p><strike>To develop a plugin you need to create a few directories to keep things together.</strike><br /> プラグインを開発するには、いくつかのディレクトリを定型で作る必要がある。<br /> </p><p><strike>So let's create following directories:</strike><br /> 以下のディレクトリをつくってみよう。<br />  </p><pre class="tmtrac">./helloworld-plugin/<br />./helloworld-plugin/helloworld/<br />./helloworld-plugin/TracHelloworld.egg-info/<br /></pre> <h2 id="Main plugin">Main plugin</h2> <p><strike>The first step is to generate the main module for this plugin. We will construct a simple plugin that will display &quot;Hello world!&quot; on the screen when accessed through the /helloworld URL. The plugin also provides a &quot;Hello&quot; button that is, by default, rendered on the far right in the main navigation bar.</strike><br /> 第一に行うのは、プラグインのメインモジュールの作成です。<br /> これから、/helloworldというURLリクエストに対して&quot;Hello world!&quot;とだけ表示する、簡単なプラグインを作ります。<br /> このプラグインはメインナビゲーションバーに&quot;Hello&quot;ボタンを表示します。<br />  </p><p><strike>So create <em>helloworld.py</em> in <em>./helloworld-plugin/helloworld/</em>:</strike><br /> ./helloworld-plugin/helloworld/にhelloworld.pyを作ります。<br />  </p><pre class="tmtrac"># Helloworld plugin<br /><br />from trac.core import *<br />from trac.web.chrome import INavigationContributor<br />from trac.web.main import IRequestHandler<br />from trac.util import escape, Markup<br /><br />class UserbaseModule(Component):<br />    implements(INavigationContributor, IRequestHandler)<br /><br />    # INavigationContributor methods<br />    def get_active_navigation_item(self, req):<br />        return 'helloworld'<br />                <br />    def get_navigation_items(self, req):<br />        yield 'mainnav', 'helloworld', Markup('&lt;a xhref=&quot;%s&quot;&gt;Hello&lt;/a&gt;', self.env.href.helloworld())<br /><br />    # IRequestHandler methods<br />    def match_request(self, req):<br />        return req.path_info == '/helloworld'<br />    <br />    def process_request(self, req):<br />        req.send_response(200)<br />        req.send_header('Content-Type', 'text/plain')<br />        req.end_headers()<br />        req.write('Hello world!')<br />        <br />        <br /></pre> <h2 id="Make it a module">Make it a module</h2> <p><strike>To make the plugin a module, you simply create an <em>_</em><em>_init_</em><em>_.py</em> in <em>./helloworld-plugin/helloworld/</em>:</strike><br /> プラグインモジュールを作るには、ただ単に、__init__.pyを./helloworld-plugin/helloworld/に置けばよい。<br />  </p><pre class="tmtrac"># Helloworld module<br />from helloworld import *<br /></pre> <h2 id="Make it an egg">Make it an egg</h2> <p><span style="text-decoration: line-through">Now it's time to make it an egg. For that we need a chicken called </span><em style="text-decoration: line-through">setup.py</em><span style="text-decoration: line-through"> in </span><em style="text-decoration: line-through">./helloworld-plugin/</em><span style="text-decoration: line-through">:</span><br /> では、eggを作ろう。そのためには、./helloworld-plugin/にsetup.py(私たちはニワトリと呼ぶべき)が必要。<br />  </p><pre class="tmtrac">from setuptools import setup<br /><br />PACKAGE = 'TracHelloworld'<br />VERSION = '0.1'<br /><br />setup(name=PACKAGE,<br />      version=VERSION,<br />      packages=['helloworld'],<br />      entry_points={'trac.plugins': '%s = helloworld' % PACKAGE},<br />)</pre><h2 id="First deployment">First deployment</h2> <p><span style="text-decoration: line-through">Now try to build the plugin. Run the command python setup.py bdist_egg in the directory where you created it. If everthing went OK you should have a .egg file in </span><em style="text-decoration: line-through">./dist</em> directory.<br /> プラグインをビルドしてみる。以下のコマンドをあなたが作ったディレクトリで実行する。もし、すべてうまくいけば ./dist ディレクトリに .eggファイルができている。<br /> </p> <pre>python setup.py bdist_egg <br /><br /></pre> <p>&nbsp;</p> <p><span style="text-decoration: line-through">Copy this </span><em style="text-decoration: line-through">.egg</em><span style="text-decoration: line-through"> file to </span><em style="text-decoration: line-through">/[your trac env]/plugins</em><span style="text-decoration: line-through"> directory. If you're using mod_python you have to restart Apache.</span><br /> .eggファイルを /[あなたの!TracEnv]/plugins ディレクトリにコピーしてください。もしmod_pythonを使っているなら、Apacheを再起動してください。<br />  </p><p><span style="text-decoration: line-through">Now you should see </span><em style="text-decoration: line-through">Hello</em><span style="text-decoration: line-through"> link at far right in main navigation bar when accessing your site. Click it.</span><br /> メインナビゲーションバーの一番右にHelloリンクが見えているはずです。クリックしてみてください。<br />  </p><h2 id="Aftermath">Aftermath</h2> <p><span style="text-decoration: line-through">Now you have successfully created your first egg. You can continue by reading </span>[wiki:EggCookingTutorial/AdvancedEggCooking EggCookingTutorial/AdvancedEggCooking]      <span style="text-decoration: line-through">  to learn how to use templates in your plugins, and make its output look like other Trac pages.</span><br /> 以上で、ファーストエッグの作成は終わりです。他のTracのページのようにプラグインでテンプレートを使いたければ、続けて、[wiki:TracDoc/AdvancedEggCookingja EggCookingTutorial/AdvancedEggCooking]     を読んでください。  </p><p>&nbsp;</p> <p>&nbsp;</p> <hr style="width: 100%; height: 2px" />訳注:以下は、どこかのページに書いてあった、開発の再に便利な方法  <p><span style="text-decoration: line-through">To deploy a plugin only to a specific Trac environment, copy the egg file into the plugins directory of that environment:</span><br /> </p> <ul>   <li>eggを作って、TracEnvに置く方法:</li> </ul>  <pre class="tmtrac">$ cd /path/to/pluginsource<br />$ python setup.py bdist_egg<br />$ cp dist/*.egg /path/to/projenv/plugins<br /></pre>   <p><span style="text-decoration: line-through">During development of a plugin, it is inconvenient to have to install it in either of the ways described above. Instead, you should use the setuptools develop command:</span> </p>  <ul>   <li>開発中に、いちいちインストールしなくてすむ方法。<br />   </li>  </ul>  <pre class="tmtrac">$ cd /path/to/pluginsource<br />$ python setup.py develop --install-dir=/path/to/projenv/plugins<br /></pre> <p>You can omit the --install-dir argument to make the development version of your plugin available globally. </p><p><strike>This will install an .egg-link file instead of the actual egg. That file is basically a link to the source directory of your plugin, so that Trac will always see the latest version of your code.</strike><br /> .egg-linkファイルが実際のeggファイルの代わりに出来る。このファイルは基本的にソースディレクトリへのリンクであるので、Tracは常に最新のソースを使うことになる。<br />  </p><p>&nbsp;(2006/04/12)</p> 
     3<h1 id="Egg cooking">Egg cooking</h1><br /> [http://trac-hacks.org/wiki/EggCookingTutorial/BasicEggCooking 原文]   [[VisitCounter(TracDoc/BasicEggCookingJa)]]      <br /> <br />  <p><strike>Since Trac 0.9 it has been possible to write plugins for Trac to extend Trac functionality. Even better, you can deploy plugins as [http://peak.telecommunity.com/DevCenter/PythonEggs Python eggs]           that really makes plugin development fun and easy.</strike> </p><p>こ のチュートリアルはeggを作る方法とeggをTracにロードする方法を示します。なお、Advanced Partsで、テンプレートや静的コンテンツをeggから提 供する方法を学ぶ。 This tutorial shows how to make an egg, and load an egg in Trac. In the advanced parts you'll learn how to serve templates and static content from an egg. </p><p><strike>You should be familiar with [trac:TracDev/ComponentArchitecture component architecture]           and [trac:TracDev/PluginDevelopment plugin development]          . This plugin is based on the example in the plugin development article. <em>Here we extend it a bit further.</em></strike></p> <p>あなたは、[http://projects.edgewall.com/trac/wiki/TracDev/ComponentArchitecture component architecture]          や [wiki:TracDoc/PluginDevelopmentJa plugin development]          も見ておくべき。今回のプラグインはplugin developmentの記事の例に基づいている。ここでは、それにちょっと深入りするけど。 </p> <h2 id="Required items (必要なもの) ">Required items (必要なもの) </h2> <p><strike>First you need <em>setuptools</em>. For instructions and files see [http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install EasyInstall]           page. </strike></p><p><strike>You also need Trac 0.9.  Download it from the [trac:TracDownload#LatestDevelopmentRelease0.9beta2 TracDownload]           page.</strike><br /> </p> <p>まず、setuptoolsが必要。[http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install EasyInstall]         を参照。<br /> Trac0.9も必要。<br />  </p> <h2 id="Directories">Directories</h2> <p><strike>To develop a plugin you need to create a few directories to keep things together.</strike><br /> プラグインを開発するには、いくつかのディレクトリを定型で作る必要がある。<br /> </p><p><strike>So let's create following directories:</strike><br /> 以下のディレクトリをつくってみよう。<br />  </p><pre class="tmtrac">./helloworld-plugin/<br />./helloworld-plugin/helloworld/<br />./helloworld-plugin/TracHelloworld.egg-info/<br /></pre> <h2 id="Main plugin">Main plugin</h2> <p><strike>The first step is to generate the main module for this plugin. We will construct a simple plugin that will display &quot;Hello world!&quot; on the screen when accessed through the /helloworld URL. The plugin also provides a &quot;Hello&quot; button that is, by default, rendered on the far right in the main navigation bar.</strike><br /> 第一に行うのは、プラグインのメインモジュールの作成です。<br /> これから、/helloworldというURLリクエストに対して&quot;Hello world!&quot;とだけ表示する、簡単なプラグインを作ります。<br /> このプラグインはメインナビゲーションバーに&quot;Hello&quot;ボタンを表示します。<br />  </p><p><strike>So create <em>helloworld.py</em> in <em>./helloworld-plugin/helloworld/</em>:</strike><br /> ./helloworld-plugin/helloworld/にhelloworld.pyを作ります。<br />  </p><pre class="tmtrac"># Helloworld plugin<br /><br />from trac.core import *<br />from trac.web.chrome import INavigationContributor<br />from trac.web.main import IRequestHandler<br />from trac.util import escape, Markup<br /><br />class UserbaseModule(Component):<br />    implements(INavigationContributor, IRequestHandler)<br /><br />    # INavigationContributor methods<br />    def get_active_navigation_item(self, req):<br />        return 'helloworld'<br />                <br />    def get_navigation_items(self, req):<br />        yield 'mainnav', 'helloworld', Markup('&lt;a xhref=&quot;%s&quot;&gt;Hello&lt;/a&gt;', self.env.href.helloworld())<br /><br />    # IRequestHandler methods<br />    def match_request(self, req):<br />        return req.path_info == '/helloworld'<br />    <br />    def process_request(self, req):<br />        req.send_response(200)<br />        req.send_header('Content-Type', 'text/plain')<br />        req.end_headers()<br />        req.write('Hello world!')<br />        <br />        <br /></pre> <h2 id="Make it a module">Make it a module</h2> <p><strike>To make the plugin a module, you simply create an <em>_</em><em>_init_</em><em>_.py</em> in <em>./helloworld-plugin/helloworld/</em>:</strike><br /> プラグインモジュールを作るには、ただ単に、__init__.pyを./helloworld-plugin/helloworld/に置けばよい。<br />  </p><pre class="tmtrac"># Helloworld module<br />from helloworld import *<br /></pre> <h2 id="Make it an egg">Make it an egg</h2> <p><span style="text-decoration: line-through">Now it's time to make it an egg. For that we need a chicken called </span><em style="text-decoration: line-through">setup.py</em><span style="text-decoration: line-through"> in </span><em style="text-decoration: line-through">./helloworld-plugin/</em><span style="text-decoration: line-through">:</span><br /> では、eggを作ろう。そのためには、./helloworld-plugin/にsetup.py(私たちはニワトリと呼ぶべき)が必要。<br />  </p><pre class="tmtrac">from setuptools import setup<br /><br />PACKAGE = 'TracHelloworld'<br />VERSION = '0.1'<br /><br />setup(name=PACKAGE,<br />      version=VERSION,<br />      packages=['helloworld'],<br />      entry_points={'trac.plugins': '%s = helloworld' % PACKAGE},<br />)</pre><h2 id="First deployment">First deployment</h2> <p><span style="text-decoration: line-through">Now try to build the plugin. Run the command python setup.py bdist_egg in the directory where you created it. If everthing went OK you should have a .egg file in </span><em style="text-decoration: line-through">./dist</em> directory.<br /> プラグインをビルドしてみる。以下のコマンドをあなたが作ったディレクトリで実行する。もし、すべてうまくいけば ./dist ディレクトリに .eggファイルができている。<br /> </p> <pre>python setup.py bdist_egg <br /><br /></pre> <p>&nbsp;</p> <p><span style="text-decoration: line-through">Copy this </span><em style="text-decoration: line-through">.egg</em><span style="text-decoration: line-through"> file to </span><em style="text-decoration: line-through">/[your trac env]/plugins</em><span style="text-decoration: line-through"> directory. If you're using mod_python you have to restart Apache.</span><br /> .eggファイルを /[あなたの!TracEnv]/plugins ディレクトリにコピーしてください。もしmod_pythonを使っているなら、Apacheを再起動してください。<br />  </p><p><span style="text-decoration: line-through">Now you should see </span><em style="text-decoration: line-through">Hello</em><span style="text-decoration: line-through"> link at far right in main navigation bar when accessing your site. Click it.</span><br /> メインナビゲーションバーの一番右にHelloリンクが見えているはずです。クリックしてみてください。<br />  </p><h2 id="Aftermath">Aftermath</h2> <p><span style="text-decoration: line-through">Now you have successfully created your first egg. You can continue by reading </span>[wiki:EggCookingTutorial/AdvancedEggCooking EggCookingTutorial/AdvancedEggCooking]         <span style="text-decoration: line-through">  to learn how to use templates in your plugins, and make its output look like other Trac pages.</span><br /> 以上で、ファーストエッグの作成は終わりです。他のTracのページのようにプラグインでテンプレートを使いたければ、続けて、[wiki:TracDoc/AdvancedEggCookingja EggCookingTutorial/AdvancedEggCooking]        を読んでください。  </p><p>&nbsp;</p> <p>&nbsp;</p> <hr style="width: 100%; height: 2px" />訳注:以下は、どこかのページに書いてあった、開発の再に便利な方法  <p><span style="text-decoration: line-through">To deploy a plugin only to a specific Trac environment, copy the egg file into the plugins directory of that environment:</span><br /> </p> <ul>   <li>eggを作って、TracEnvに置く方法:</li> </ul>  <pre class="tmtrac">$ cd /path/to/pluginsource<br />$ python setup.py bdist_egg<br />$ cp dist/*.egg /path/to/projenv/plugins<br /></pre>   <p><span style="text-decoration: line-through">During development of a plugin, it is inconvenient to have to install it in either of the ways described above. Instead, you should use the setuptools develop command:</span> </p>  <ul>   <li>開発中に、いちいちインストールしなくてすむ方法。<br />   </li>  </ul>  <pre class="tmtrac">$ cd /path/to/pluginsource<br />$ python setup.py develop --install-dir=/path/to/projenv/plugins<br /></pre> <p>You can omit the --install-dir argument to make the development version of your plugin available globally. </p><p><strike>This will install an .egg-link file instead of the actual egg. That file is basically a link to the source directory of your plugin, so that Trac will always see the latest version of your code.</strike><br /> .egg-linkファイルが実際のeggファイルの代わりに出来る。このファイルは基本的にソースディレクトリへのリンクであるので、Tracは常に最新のソースを使うことになる。<br />  </p><p> (2006/04/12)</p> 
    44}}}