Modify

Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#9256 closed enhancement (fixed)

Use configuration API instead of directly using `self.config.get()`.

Reported by: jun66j5 Owned by: iwata0303
Priority: normal Component: TracBlockDiagPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.12

Description

The plugin retrieves directly the configurations using self.config.get().

I think it should use configuration API instead. It would be able to edit the configuration via iniadmin.

  • blockdiagplugin/web_ui.py

     
    88 
    99 
    1010from trac.core import * 
     11from trac.config import Option 
    1112from trac.wiki import IWikiMacroProvider 
    1213from trac.web import IRequestHandler  
    1314from trac.wiki.formatter import system_message 
     
    104105        http://tk0miya.bitbucket.org/actdiag/build/html/index.html and http://tk0miya.bitbucket.org/nwdiag/build/html/index.html 
    105106    """ 
    106107    implements (IWikiMacroProvider, IRequestHandler) 
     108 
     109    _default_type = Option('blockdiag', 'default_type', 'png', 
     110        doc="Default output format type which will be used when the type " 
     111            "isn't given.") 
     112 
     113    _font = Option('blockdiag', 'font', '', 
     114        doc="Path to a font file to draw a diagram.") 
    107115     
    108116    macros = None 
    109117 
     
    128136        if name[-4:] in ('_svg', '_png'): 
    129137            name, type = name.split('_') 
    130138        else: 
    131             type = (args.get('type') or self.env.config.get('blockdiag', 'default_type', 'png')).lower() 
     139            type = (args.get('type') or self._default_type).lower() 
    132140            if type not in ('svg', 'png'): 
    133141                return system_message("Invalid type(%s). Type must be 'svg' or 'png'" % type) 
    134142                 
    135         font = self.env.config.get('blockdiag', 'font', '') 
     143        font = self._font 
    136144 
    137145        # nonascii unicode can't be passed to hashlib. 
    138146        id = make_hash('%s,%s,%s,%r' % (name, type, font, content)).hexdigest() 

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by iwata0303

(In [10908]) see #9256 Use configuration API instead of direct access to Component.config.get (Thanks jun66j5)

comment:2 Changed 2 years ago by rjollos

  • Resolution set to fixed
  • Status changed from new to closed

comment:3 Changed 2 years ago by rjollos

Btw, I closed this because it looked like someone just forgot to do that, but please correct if I'm wrong.

Add Comment

Modify Ticket

Action
as closed .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from iwata0303. Next status will be 'closed'.
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.