
dr2chase at mac
Nov 2, 2009, 7:33 PM
Post #6 of 6
(106 views)
Permalink
|
|
Re: Confused about "PathOption" in a plugin/macro
[In reply to]
|
|
Works now, including that plugin, thanks very much. Working code sample (hope this fits...) class fssMacro(WikiMacroBase): """Fortress ASCII/Formatted display macro. """ fsspath=PathOption('fss','fortifypath', None,"""Path to the directory containing the fortify .el and .sty files.""") basename=Option('fss', 'fortify','newfortify',"""Basename of the .el and .sty files in the fortify directory.""") destdir=PathOption('fss', 'cache', '../htdocs/fortified/ tracfss',"""Path to the cache where the generated images are cached.""") urlbase=Option('fss','cacheurl', '.../chrome/site/fortified/ tracfss',"""URL for the generated images cache.""") latexpath=PathOption('fss', 'latexroot', None,"""Path to the directory containing the varies latex binaries.""") attachments=PathOption('fss', 'attachments','../attachments',"""Path to the directory where attachments are stored. The default setting should work.""") latex=Option('fss', 'latex', 'latex',"""Name of the latex binary.""") pdflatex=Option('fss', 'pdflatex', 'pdflatex',"""Name of the pdflatex binary.""") dvipng=Option('fss', 'dvipng', 'dvipng',"""Name of the dvipng binary.""") emacspath=PathOption('fss','emacs', None,"""Path to the emacs binary.""") On 2009-10-30, at 11:38 PM, Noah Kantrowitz wrote: > On Oct 30, 2009, at 2:01 PM, David Chase wrote: >> On 2009-10-30, at 4:42 PM, Noah Kantrowitz wrote: >> >>> The *Option classes are accessors, you use them in the context of >>> the class >>> definition like this: >>> >>> class Blah(Component): >>> latex_path = PathOption('fss', etc etc) >>> >>> def my_plugin_function(self, req): >>> print self.latex_path >> ... > > Yes, when you access it through self (through an object) you get the > value from the config. If you access it via the class > (Blah.latex_path) you get the PathOption object. Its a bit of magic in > how Python does attribute lookups, it ends up invoking code within the > PathOption object which ends up returning the config value. You should > definitely use the *Option classes in favor of the direct self.config > access so you get the auto-magic stuff in the IniAdmin plugin (and > anything else that introspects those, like the TracIni macro). > > --Noah --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Trac Users" group. To post to this group, send email to trac-users[at]googlegroups.com To unsubscribe from this group, send email to trac-users+unsubscribe[at]googlegroups.com For more options, visit this group at http://groups.google.com/group/trac-users?hl=en -~----------~----~----~----~------~----~------~--~---
|