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

--

インタフェースのリファレンス

Tracは、ComponentArchitectureに基づき多くのインタフェースをプラグイン開発者に提供しています。
が、資料はほとんどないので、ここにまとめてみました。

インタフェース一覧

0.10で若干インタフェースが増えてるようです。

パッケージインタフェースTrac 0.9Trac 0.10
trac.db.apiIDatabaseConnector?-
trac.mimeview.apiIHTMLPreviewRenderer
trac.mimeview.apiIHTMLPreviewAnnotator
trac.tests.coreITest-
trac.ticket.apiITicketChangeListener-
trac.ticket.apiITicketManipulator-
trac.versioncontrol.apiIRepositoryConnector
trac.web.apiIAuthenticator
trac.web.apiIRequestHandler
trac.web.chromeINavigationContributor
trac.web.chromeITemplateProvider
trac.wiki.apiIWikiChangeListener
trac.wiki.apiIWikiPageManipulator-
trac.wiki.apiIWikiMacroProvider
trac.wiki.apiIWikiSyntaxProvider
trac.envIEnvironmentSetupParticipant
trac.permIPermissionRequestor
trac.permIPermissionStore
trac.permIPermissionGroupProvider
trac.SearchISearchSource
trac.TimelineITimelineEventProvider

リファレンス

IDatabaseConnector

Trac 0.10以降。DB接続先を変えるためのインタフェースみたいです。

class IDatabaseConnector(Interface):
    """Extension point interface for components that support the connection to
    relational databases."""

    def get_supported_schemes():
        """Return the connection URL schemes supported by the connector, and
        their relative priorities as an iterable of `(scheme, priority)` tuples.
        """

    def get_connection(**kwargs):
        """Create a new connection to the database."""
        
    def init_db(**kwargs):
        """Initialize the database."""

    def to_sql(table):
        """Return the DDL statements necessary to create the specified table,
        including indices."""

IHTMLPreviewRenderer

リポジトリブラウザで、MimeTypeに紐づくHTMLを出力するためのインタフェース。 特定のMimeTypeに対して、リポジトリブラウザでデータを見せたいときにこれを使います。

class IHTMLPreviewRenderer(Interface):
    """Extension point interface for components that add HTML renderers of
    specific content types to the `Mimeview` component.
    """

    # implementing classes should set this property to True if they
    # support text content where Trac should expand tabs into spaces
    expand_tabs = False

    def get_quality_ratio(mimetype):
        """Return the level of support this renderer provides for the `content`
        of the specified MIME type. The return value must be a number between
        0 and 9, where 0 means no support and 9 means "perfect" support.
        """

    def render(req, mimetype, content, filename=None, url=None):
        """Render an XHTML preview of the raw `content`.

        The `content` might be:
         * a `str` object
         * an `unicode` string
         * any object with a `read` method, returning one of the above

        It is assumed that the content will correspond to the given `mimetype`.

        Besides the `content` value, the same content may eventually
        be available through the `filename` or `url` parameters.
        This is useful for renderers that embed objects, using <object> or
        <img> instead of including the content inline.
        
        Can return the generated XHTML text as a single string or as an
        iterable that yields strings. In the latter case, the list will
        be considered to correspond to lines of text in the original content.
        """

サンプル: source:/trunk/xdocviewplugin/xdocview/xdocview.py#36

IHTMLPreviewAnnotator

IHTMLPreviewRendererと似てますが、これはXHTML版なのかな?使ってるのは見たことありません。

class IHTMLPreviewAnnotator(Interface):
    """Extension point interface for components that can annotate an XHTML
    representation of file contents with additional information."""

    def get_annotation_type():
        """Return a (type, label, description) tuple that defines the type of
        annotation and provides human readable names. The `type` element should
        be unique to the annotator. The `label` element is used as column
        heading for the table, while `description` is used as a display name to
        let the user toggle the appearance of the annotation type.
        """

    def annotate_line(number, content):
        """Return the XHTML markup for the table cell that contains the
        annotation data."""