Edgewall Software

Changes between Version 1 and Version 2 of TracDev/Options


Ignore:
Timestamp:
Dec 17, 2010, 3:58:54 PM (13 years ago)
Author:
anatoly techtonik <techtonik@…>
Comment:

example how to get option

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/Options

    v1 v2  
    11This page describes how to work with options or settings stored in `trac.ini` from your Plugin. Feel free to expand.
    22
    3 Trac plugins don't have access to some kind of global options. Options are only available for plugin components through the `self.config` [wiki:TracDev/PluginDevelopment#Componentmembervariables property]. This property is magically (i.e. implicitly) injected into Component when it is created - see [wiki:TracDev/ComponentArchitecture#component_lifecycle activation chapter] for details.
     3Trac plugins don't have access to some kind of global options. Options are only available for plugin components through the `self.config` [wiki:TracDev/PluginDevelopment#Componentmembervariables property]. This property is magically (i.e. implicitly) injected into component when it is created - see [wiki:TracDev/ComponentArchitecture#component_lifecycle activation chapter] for details. `self.config` is an instance of [source:trunk/trac/config.py trac.config.Configuration] class.
    44
     5=== Get option value
     6
     7[source:trunk/trac/config.py trac.config.Configuration] is a subclass of [http://docs.python.org/library/configparser.html ConfigParser] from standard Python library, therefore all its methods and more are accessible.
     8
     9{{{
     10# inside component
     11self.config.get('section', 'option', 'default')
     12}}}