From d8e113c4cd810d317b1d0dc1c4ae0993b691b9ec Mon Sep 17 00:00:00 2001 From: helmutm Date: Thu, 1 Jul 2010 09:48:30 +0000 Subject: [PATCH] provide method for set an individual option git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@3912 fd906abe-77d9-0310-91a1-e0d9ade77398 --- config/base.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config/base.py b/config/base.py index 7d8c0f8..391f181 100644 --- a/config/base.py +++ b/config/base.py @@ -90,6 +90,23 @@ class LoopsOptions(Options): if rc: raise ExecutionError('\n' + rc) + def set(self, key, value): + options = getattr(self.context, 'options', []) + new_opt = [] + for item in options: + parts = item.split(':', 1) + if parts[0] == key: + if not value: + continue + if value is True: + item = key + continue + elif isinstance(value, (list, tuple)): + value = ','.join(value) + item = '%s:%s' % (key, value) + new_opt.append(item) + self.context.options = new_opt + class TypeOptions(LoopsOptions):