anatoly techtonik wrote:
> In http://trac.edgewall.org/ticket/7757 it is said that
> ComponentManager() is not a part of public API. How should I
> instantiate a component then if I need to use it from my code?

It *is* part of the public API. The only thing is that you can't import
it with:

  from trac.core import *

You would need to do it with:

  from trac.core import ComponentManager

But you are trying to do things much more complicated than necessary.
Stop worrying about ComponentManager.

> For example, I need to create a patch with new extension point for
> Trac, so I define a component and instantiate it from withing ordinary
> object.

You don't instantiate components, you let the environment instantiate it
for you. You need to do three things for this to work:

 - Create a subclass of Component
 - Enable the component in the [components] section of trac.ini
 - Place your code in a location accessible to Trac (typically the
plugins directory of the environment)

Don't forget to restart your web server or tracd when you make changes
to the plugin. If you do all of this correctly, Trac will load your
plugin and instantiate the component. You should see that in the log,
provided the logging level is set to DEBUG.

> Another scenario - I want my plugin to use logger from Environment.
> How can I get it?

When the environment instantiates your component, it will place a .log
attribute in the instance, which is a reference to a logger object that
writes to the Trac log. So you can just write:

  self.log.debug("...")

-- Remy

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to