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

初期バージョン から バージョン 1 における更新: TracDoc/Interface

差分発生行の前後
無視リスト:
更新日時:
2006/05/07 21:49:55 (19 年 前)
更新者:
weekbuild (IP アドレス: 220.211.12.31)
コメント:

--

凡例:

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

    v1 v1  
     1= インタフェースのリファレンス = 
     2Tracは、[wiki:TracDoc/ComponentArhitectureJa ComponentArchitecture]に基づき多くのインタフェースをプラグイン開発者に提供しています。[[BR]] 
     3が、資料はほとんどないので、ここにまとめてみました。 
     4 
     5== インタフェース一覧 == 
     60.10で若干インタフェースが増えてるようです。 
     7 
     8||パッケージ||インタフェース||Trac 0.9||Trac 0.10|| 
     9||trac.db.api||IDatabaseConnector||-||○|| 
     10||trac.mimeview.api||IHTMLPreviewRenderer||○||○|| 
     11||trac.mimeview.api||IHTMLPreviewAnnotator||○||○|| 
     12||trac.tests.core||ITest||-||○|| 
     13||trac.ticket.api||ITicketChangeListener||-||○|| 
     14||trac.ticket.api||ITicketManipulator||-||○|| 
     15||trac.versioncontrol.api||IRepositoryConnector||||○|| 
     16||trac.web.api||IAuthenticator||○||○|| 
     17||trac.web.api||IRequestHandler||○||○|| 
     18||trac.web.chrome||INavigationContributor||○||○|| 
     19||trac.web.chrome||ITemplateProvider||○||○|| 
     20||trac.wiki.api||IWikiChangeListener||○||○|| 
     21||trac.wiki.api||IWikiPageManipulator||-||○|| 
     22||trac.wiki.api||IWikiMacroProvider||○||○|| 
     23||trac.wiki.api||IWikiSyntaxProvider||○||○|| 
     24||trac.env||IEnvironmentSetupParticipant||○||○|| 
     25||trac.perm||IPermissionRequestor||○||○|| 
     26||trac.perm||IPermissionStore||○||○|| 
     27||trac.perm||IPermissionGroupProvider||○||○|| 
     28||trac.Search||ISearchSource||○||○|| 
     29||trac.Timeline||ITimelineEventProvider||○||○|| 
     30 
     31== リファレンス == 
     32=== IDatabaseConnector === 
     33Trac 0.10以降。DB接続先を変えるためのインタフェースみたいです。 
     34{{{ 
     35#!python 
     36class IDatabaseConnector(Interface): 
     37    """Extension point interface for components that support the connection to 
     38    relational databases.""" 
     39 
     40    def get_supported_schemes(): 
     41        """Return the connection URL schemes supported by the connector, and 
     42        their relative priorities as an iterable of `(scheme, priority)` tuples. 
     43        """ 
     44 
     45    def get_connection(**kwargs): 
     46        """Create a new connection to the database.""" 
     47         
     48    def init_db(**kwargs): 
     49        """Initialize the database.""" 
     50 
     51    def to_sql(table): 
     52        """Return the DDL statements necessary to create the specified table, 
     53        including indices.""" 
     54}}} 
     55=== IHTMLPreviewRenderer === 
     56リポジトリブラウザで、MimeTypeに紐づくHTMLを出力するためのインタフェース。 
     57特定のMimeTypeに対して、リポジトリブラウザでデータを見せたいときにこれを使います。 
     58{{{ 
     59class IHTMLPreviewRenderer(Interface): 
     60    """Extension point interface for components that add HTML renderers of 
     61    specific content types to the `Mimeview` component. 
     62    """ 
     63 
     64    # implementing classes should set this property to True if they 
     65    # support text content where Trac should expand tabs into spaces 
     66    expand_tabs = False 
     67 
     68    def get_quality_ratio(mimetype): 
     69        """Return the level of support this renderer provides for the `content` 
     70        of the specified MIME type. The return value must be a number between 
     71        0 and 9, where 0 means no support and 9 means "perfect" support. 
     72        """ 
     73 
     74    def render(req, mimetype, content, filename=None, url=None): 
     75        """Render an XHTML preview of the raw `content`. 
     76 
     77        The `content` might be: 
     78         * a `str` object 
     79         * an `unicode` string 
     80         * any object with a `read` method, returning one of the above 
     81 
     82        It is assumed that the content will correspond to the given `mimetype`. 
     83 
     84        Besides the `content` value, the same content may eventually 
     85        be available through the `filename` or `url` parameters. 
     86        This is useful for renderers that embed objects, using <object> or 
     87        <img> instead of including the content inline. 
     88         
     89        Can return the generated XHTML text as a single string or as an 
     90        iterable that yields strings. In the latter case, the list will 
     91        be considered to correspond to lines of text in the original content. 
     92        """ 
     93}}} 
     94サンプル: 
     95source:/trunk/xdocviewplugin/xdocview/xdocview.py#36 
     96=== IHTMLPreviewAnnotator === 
     97IHTMLPreviewRendererと似てますが、これはXHTML版なのかな?使ってるのは見たことありません。 
     98{{{ 
     99class IHTMLPreviewAnnotator(Interface): 
     100    """Extension point interface for components that can annotate an XHTML 
     101    representation of file contents with additional information.""" 
     102 
     103    def get_annotation_type(): 
     104        """Return a (type, label, description) tuple that defines the type of 
     105        annotation and provides human readable names. The `type` element should 
     106        be unique to the annotator. The `label` element is used as column 
     107        heading for the table, while `description` is used as a display name to 
     108        let the user toggle the appearance of the annotation type. 
     109        """ 
     110 
     111    def annotate_line(number, content): 
     112        """Return the XHTML markup for the table cell that contains the 
     113        annotation data.""" 
     114}}}