Am 22.03.2006 um 18:13 schrieb Christian Boos:
Emmanuel Blot wrote:
http://projects.edgewall.com/trac/attachment/wiki/ChristianBoos/ default_config_refactoring_and_TracIni_macro-r2979.patch

No objections for committing this?

Seems ok to me (not tested, only read).

Additionnal note: I find the syntax of the defaut parameters quite
unreadable (mostly due to the use of nested lists and string quotes)
and error prone. However, I have no suggestion about how to make it
easier to read at the moment...

Your quite right about this point: I've tried several variations,
but I'm still not happy with the result, which I find difficult
to read too...

Maybe using some kind of builder functions, to take advantage
of optional named arguments:


def section(name, *settings):
 return (name, settings)

def setting(name, default_value, since="", doc=""):
 return (name, default_value, doc, since)


default_config = \
(section('trac',
 setting('repository_type', 'svn', since="0.10",
         doc="""Repository connector type"""),
 setting('repository_dir', '',
         doc="""Path to local Subversion repository"""),


etc., you get the idea.

I would suggest not moving forward down that line, but rather refactor the config defaults to use an extension point.

   class ConfigOption(object):
      def __init__(self, section, name, default=None, doc=None):
         # xxx

   class IConfigurable(Interface):
      def get_config_options():
         # return a list of ConfigurationOption objects

(defined in trac.config, extension point for IConfigurable in Environment)

Cheers,
Chris
--
Christopher Lenz
  cmlenz at gmx.de
  http://www.cmlenz.net/

_______________________________________________
Trac-dev mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-dev

Reply via email to