Well, as the person who added the extension mechanism (to support Visit tracking and Identity) I probably ought to explain it a bit (and maybe the explanation will find its way into the documentation).

To provide an extension to TurboGears, your Egg should expose an entry point in the `turbogears.extensions` section. This entry point references a module. So setup.py for TurboGears itself has the following:

    [turbogears.extensions]
    identity = turbogears.identity.visitor
    visit = turbogears.visit

On startup and shutdown, TG will call the `start_extension` and `shutdown_extension` functions in the exposed module.

There is one more entry point for extensions, but it currently isn't hooked up to anything. Ideally tg-admin will have a `create-model` or `model create` command which would call the `create_extension_model` entry point for each extension.

Currently, Visit and Identity create their model through an explicit call to `create_extension_model` during `start_extension`.

It is the responsibility of the extension to determine whether it should be enabled or not. For example, in `start_extension` Visit checks the `visit.on` config variable and if False does not initialise Visit tracking.


On 2 Feb, 2006, at 11:18 am, Matthew Bevan wrote:

Browsing through TG's code today I noticed the attachment points for TG 

extensions seems to have been added (and well - startup and shutdown 

notification was the piece of code I saw).


My question is how can I make use of this?


--
Jeff Watkins

"Advertising directed at children is inherently deceptive and exploits children under eight years of age."
-- American Academy of Pediatrics


Reply via email to