[Checkins] SVN: cipher.configstore/trunk/src/cipher/configstore/configstore. Make sure init is called only once.
Albertas Agejevas
cvs-admin at zope.org
Tue Jun 5 19:52:19 UTC 2012
Log message for revision 126600:
Make sure init is called only once.
Changed:
U cipher.configstore/trunk/src/cipher/configstore/configstore.py
U cipher.configstore/trunk/src/cipher/configstore/configstore.txt
-=-
Modified: cipher.configstore/trunk/src/cipher/configstore/configstore.py
===================================================================
--- cipher.configstore/trunk/src/cipher/configstore/configstore.py 2012-06-05 19:32:25 UTC (rev 126599)
+++ cipher.configstore/trunk/src/cipher/configstore/configstore.py 2012-06-05 19:52:16 UTC (rev 126600)
@@ -242,9 +242,13 @@
def _applyPostAddConfig(self, item, config, section):
pass
+ def clearContext(self):
+ ctx = removeSecurityProxy(self.context)
+ for key in list(ctx):
+ del ctx[key]
+
def load(self, config):
- # Remove all existing items
- removeSecurityProxy(self.context).__init__()
+ self.clearContext()
# Load one item at a time.
for section in config.sections():
if not section.startswith(self.section_prefix):
Modified: cipher.configstore/trunk/src/cipher/configstore/configstore.txt
===================================================================
--- cipher.configstore/trunk/src/cipher/configstore/configstore.txt 2012-06-05 19:32:25 UTC (rev 126599)
+++ cipher.configstore/trunk/src/cipher/configstore/configstore.txt 2012-06-05 19:52:16 UTC (rev 126600)
@@ -200,10 +200,14 @@
>>> class PhoneNumbers(dict):
... zope.interface.implements(IPhoneNumbers)
+ ... def __init__(self):
+ ... print "Initializing PhoneNumbers"
+ ... super(PhoneNumbers, self).__init__()
... def __repr__(self):
... return '<%s %i>' %(self.__class__.__name__, len(self))
>>> numbers = PhoneNumbers()
+ Initializing PhoneNumbers
>>> numbers['home'] = PhoneNumber(u'home', u'555-111-2222')
>>> numbers['work'] = PhoneNumber(u'work', u'555-333-4444')
More information about the checkins
mailing list