On Oct 28, 1:27 pm, Remy Blank <[EMAIL PROTECTED]> wrote: > > 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)
Done. But I have to patch Trac to provide extension point to my plugin and I plugged it in existing class - http://trac.edgewall.org/attachment/ticket/781/icachechangesetlistener.diff Christian explained that it was rather unusual usage and there was no other choice than to use ComponentManager http://trac.edgewall.org/ticket/7757#comment:5 > > 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("...") Unfortunately this doesn't happen. When I place my component into plugins/ folder it is correctly loaded, but during execution fails: --- Trac detected an internal error: AttributeError: 'MantisChangesetQuery' object has no attribute 'log' --- --cut trac.log-- ... 2008-10-28 05:00:18,882 Trac[__init__] DEBUG: Loading file plugin mantis_tickets_query from /home/.december/trex/fartrac/plugins/ mantis_tickets_query.py 2008-10-28 05:00:16,987 Trac[__init__] DEBUG: Loading file plugin mantis_tickets_query from /home/.december/trex/fartrac/plugins/ mantis_tickets_query.py ... 2008-10-28 05:00:19,265 Trac[__init__] ERROR: 'MantisChangesetQuery' object has no attribute 'log' ... File "/home/.december/trex/fartrac/plugins/mantis_tickets_query.py", line 50, in edit_changeset self.log.info("Lookup bug title at Mantis webpage %s" % url) AttributeError: 'MantisChangesetQuery' object has no attribute 'log' --cut trac.log-- -- WBR, anatoly --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Trac Development" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/trac-dev?hl=en -~----------~----~----~----~------~----~------~--~---
