| バージョン 8 (更新者: weekbuild, 19 年 前) |
|---|
インタフェースのリファレンス
Tracは、ComponentArchitectureに基づき多くのインタフェースをプラグイン開発者に提供しています。
が、資料はほとんどないので、ここにまとめてみました。
インタフェース一覧
0.10で若干インタフェースが増えてるようです。
| パッケージ | インタフェース | 0.9 | 0.10 | 説明 |
| trac.db.api | IDatabaseConnector | × | ○ | DBを変更するためのインタフェース? |
| trac.mimeview.api | IHTMLPreviewRenderer | ○ | ○ | リポジトリブラウザでHTMLを表示するためのインタフェース |
| trac.mimeview.api | IHTMLPreviewAnnotator | ○ | ○ | リポジトリブラウザで付加情報を表示するためのインタフェース |
| trac.tests.core | ITest | × | ○ | |
| trac.ticket.api | ITicketChangeListener | × | ○ | |
| trac.ticket.api | ITicketManipulator | × | ○ | |
| trac.versioncontrol.api | IRepositoryConnector | × | ○ | |
| trac.web.api | IAuthenticator | ○ | ○ | |
| trac.web.api | IRequestHandler | ○ | ○ | |
| trac.web.chrome | INavigationContributor | ○ | ○ | |
| trac.web.chrome | ITemplateProvider | ○ | ○ | |
| trac.wiki.api | IWikiChangeListener | ○ | ○ | |
| trac.wiki.api | IWikiPageManipulator | × | ○ | |
| trac.wiki.api | IWikiMacroProvider | ○ | ○ | |
| trac.wiki.api | IWikiSyntaxProvider | ○ | ○ | |
| trac.env | IEnvironmentSetupParticipant | ○ | ○ | |
| trac.perm | IPermissionRequestor | ○ | ○ | |
| trac.perm | IPermissionStore | ○ | ○ | |
| trac.perm | IPermissionGroupProvider | ○ | ○ | |
| trac.Search | ISearchSource | ○ | ○ | |
| trac.Timeline | ITimelineEventProvider | ○ | ○ |
リファレンス
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."""
