[Twisted-Python] Understanding the role of .tap files
Abe Fettig
abe at fettig.net
Fri Aug 13 14:37:17 EDT 2004
Glyph,
Wow, awesome reply. That's by far the best explanation of .taps I've
come accross. Thank you!
Based on what you said, I'll probably use a simple python file for
configuration, like so:
file "hepconfig.py":
field1='rasberry sorbet'
field3='cherry garcia'
Then my application can do something like this:
defaultConfig = {'field1': 'chocolate',
'field2': 'vanilla',
'field3': 'strawberry'}
import hepconfig
userKeys = filter(lambda f: not f.startswith('_'), dir(hepconfig))
userVals = [getattr(hepconfig, key) for key in userKeys]
userConfig = dict(zip(userKeys, userVals))
for key, val in defaultConfig.items():
userConfig.setdefault(key, val)
... which results in userConfig containing:
{'field1': 'rasberry sorbet',
'field2': 'vanilla',
'field3', 'cherry garcia'}
Then I can have a single mktap option,
--configfile=/path/to/hepconfig.py (which could be hard-coded in .debs
and .rpms). I think that strikes a nice balance between avoiding a
special configuration language, and still being easy for sysadmins to
figure out.
Does that seem like a reasonable approach?
Abe
More information about the Twisted-Python
mailing list