0

I have created a plugin which is working perfectly fine!

Now I need to get access to some value in trac.ini from that plugin

The plugin is implementing ITemplateStreamFilter

the method is def filter_stream(self, req, method, filename, stream, data):

How can I get value for some key in trac.ini from that method?

bakytn
  • 344
  • 5
  • 17

1 Answers1

2

I think you could use Configuration class for this purpose config.py there implement get method:

 def get(self, section, key, default=''):
     return self[section].get(key, default)

where section is section name in config file, and key is option.

Denis
  • 7,127
  • 8
  • 37
  • 58
  • This helped me http://trac.edgewall.org/wiki/TracDev/ConfigApi I have used self.env.config.get('section', 'value') Thanks! – bakytn Jun 09 '12 at 08:07
  • it's just an article to the class of which I have given above – Denis Jun 09 '12 at 08:09
  • In filter_stream I have used "self.env.config.get" and it worked. Thanks! – bakytn Jun 09 '12 at 08:21
  • Be sure to check for other available class methods, like *.getbool()* or *.getint()* depending on the option type to simplify your own code. – hasienda Jun 10 '12 at 11:11