Edgewall Software

Changes between Version 3 and Version 4 of WikiContext


Ignore:
Timestamp:
Feb 7, 2007, 11:13:09 AM (17 years ago)
Author:
Christian Boos
Comment:

Possible future directions for the wiki context usage

Legend:

Unmodified
Added
Removed
Modified
  • WikiContext

    v3 v4  
    22= Wiki Rendering Context =
    33 
    4  '''`trac.wiki.api.Context`''' ''(Since [milestone:0.11], r4451)''
     4 '''`trac.wiki.api.Context`''' ''(current [milestone:0.11]dev, r4451)''
    55
     6 '''`trac.resource.Context`''' ''(see [#FutureDirections])''
    67
    7 === Introduction ===
     8== Introduction ==
    89
    910A Wiki rendering context contains all the information needed for properly rendering Wiki text in the Trac system:
    10  - the resource to which the wiki text belongs (`.env`, `.resource`, `.id`)
    11  - its parent context, if there's one (`.parent`)
    12  - how the rendered Wiki text is being accessed (`.req`, `.abs_urls`) so that the proper links can be generated (`.href`, `.self_href`)
     11 - Identify the resource to which the wiki text belongs (`.env`, `.realm`, `.id`)
     12 - Access to parent context, if there's one (`.parent`) [[br]]
     13   By extension, this enables one to unwind the stack of context embedding
     14 - Knows about how the rendered Wiki text is being accessed (`.req`, `.abs_urls`)
     15   so that the proper links can be generated:
     16   - `.href`: the appropriate Href instance for generating any kind of links
     17   - `.self_href`: a link targeting the current Wiki context itself [[br]]
     18     ''renamed to `.resource_href` in the security branch''
     19 - ''Allow easy access to the corresponding resource itself (`.resource`) - security branch only''
    1320
    1421Besides, it keeps a handle to a database connection (`.db`) the way the `Formatter` objects used to do.
    1522
    16 Such a context can be used for generating wiki texts in different flavors, using the `.wiki_to_...` methods.
     23Such a context can be used for generating wiki texts in different flavors, using the `.wiki_to_...` methods. ''Note: this is susceptible to change''
    1724
    1825It's very easy to manipulate contexts, or create sub-contexts. Here are some examples:
    19  - `Context(env, req)`: a global context, not attached to a particular resource
    20  - `Context(env, req, 'wiki', 'WikiStart')`: a context for the WikiStart wiki page
    21  - assuming `ctxt` is a Context instance, `ctxt('ticket', ticket.id)` creates a subcontext focusing on a specific `ticket`.
     26 - `Context(env, req)`: a toplevel context, not attached to a particular resource
     27 - `Context(env, req)('wiki', 'WikiStart')`: a context for the WikiStart wiki page
     28 - assuming `ctxt` is already some Context instance,
     29   `ctxt('ticket', ticket.id)` creates a sub-context for a specific `ticket`.
    2230
    2331
    24 === Fixed Issues ===
     32== Fixed Issues ==
    2533
    2634Thanks to Wiki rendering contexts, the following issues could be solved:
    2735 - relative attachments and comments TracLinks now always refer to the correct context resource, irrelevant from where they are displayed (ticket query with description #3711, headings #3842, timeline, etc.)
    28  - relative links (i.e. `[#anchor see this]` kind of TracLinks) are now always refering to the correct resource (#4144)
     36 - relative links (i.e. `[#anchor see this]` kind of TracLinks) are now always referring to the correct resource (#4144)
    2937
    3038Besides, a few other fixes were done at the same time:
     
    4452
    4553
    46 === API Changes ===
     54== API Changes ==
    4755
    4856Besides the new trac.wiki.api.Context class, a few existing interfaces have been modified:
    49  - `IWikiMacroProvider.render_macro` now takes a `formatter` instead of a `req` as its first argument (#4139)
     57 - `IWikiMacroProvider.render_macro` still takes a `req` as its first argument (#4139),
     58   but it's now deprecated and `IWikiMacroProvider.expand_macro` should be preferred,
     59   as it takes a `formatter` as its first argument. This is more useful than a `req`,
     60   as the formatter also provides access to the current wiki Context
     61   (`formatter.context`).
    5062 - `IHTMLPreviewRenderer.render` takes a `context` instead of a `req` as its first argument
    5163 - `TimelineEvent.set_context` takes a `context` first argument and a `wikitext` second argument. That wiki text can now be retrieved in the `.wikitext` property instead of the `.message` one.
    5264
     65
     66== Future Directions ==
     67
     68=== Fine-grained Permission Checking ===
     69
     70The source:sandbox/security branch already contains a much empowered version of the Context class.
     71
     72As a context can describe precisely ''which'' resource is accessed and at the same time ''how'' it is accessed (and more specifically ''who'' accesses it), it is also a perfect fit for the fine-grained PermissionPolicy (see also the [PermissionPolicy@16 design document]).
     73
     74In order to be used as a lightweight descriptor of a resource, Context can also be subclassed. The user of a context doesn't need to have to think about this, as the correct subclass is always used, based on the `.realm` information.
     75
     76=== Multiple Project Support ===
     77
     78Attaching the `.project` information to a Context, as an additional identifier for a Context would be a convenient way to convey the notion of a "current" project.
     79Therefore, TracLinks found in a wiki text will naturally be based in the same project as the one specified by the current WikiContext.
     80
     81InterTrac links, on the other hand, would have to be used to refer to a resource found in ''another'' project. This is a natural extension for InterTrac prefixes, which are already used to refer to resources located in ''external environments''. It would only take to identify the InterTrac prefixes corresponding to sibling projects for having this mechanism working for targeting ''other projects'' in the ''same environment''.
     82
    5383----
    5484See also: r4442 (relative TracLinks changes), PermissionPolicy (reuse Context as permission resource identifiers)