[Checkins] SVN: cipher.configstore/trunk/ - Provide ``container`` and ``root`` attributes on IConfigurationStore
Adam Groszer
cvs-admin at zope.org
Thu Aug 30 15:03:16 UTC 2012
Log message for revision 127642:
- Provide ``container`` and ``root`` attributes on IConfigurationStore
they come handy in various load and dump situation instead of __parent__
and getSite
Changed:
U cipher.configstore/trunk/CHANGES.txt
U cipher.configstore/trunk/src/cipher/configstore/configstore.py
U cipher.configstore/trunk/src/cipher/configstore/interfaces.py
-=-
Modified: cipher.configstore/trunk/CHANGES.txt
===================================================================
--- cipher.configstore/trunk/CHANGES.txt 2012-08-30 14:56:16 UTC (rev 127641)
+++ cipher.configstore/trunk/CHANGES.txt 2012-08-30 15:03:12 UTC (rev 127642)
@@ -5,7 +5,9 @@
1.2.2 (unrelease)
-----------------
-- No changes yet.
+- Provide ``container`` and ``root`` attributes on IConfigurationStore
+ they come handy in various load and dump situation instead of __parent__
+ and getSite
1.2.1 (2012-06-05)
------------------
Modified: cipher.configstore/trunk/src/cipher/configstore/configstore.py
===================================================================
--- cipher.configstore/trunk/src/cipher/configstore/configstore.py 2012-08-30 14:56:16 UTC (rev 127641)
+++ cipher.configstore/trunk/src/cipher/configstore/configstore.py 2012-08-30 15:03:12 UTC (rev 127642)
@@ -52,6 +52,8 @@
schema = None
fields = None
section = None
+ container = None
+ root = None
def __init__(self, context, schema=None, section=None):
if self.schema is None:
@@ -144,6 +146,7 @@
(self.context,), interfaces.IConfigurationStore)
for store in stores:
if not isinstance(store, self.__class__):
+ store.root = self.root
store.load(config)
zope.event.notify(
interfaces.ObjectConfigurationLoadedEvent(
@@ -215,6 +218,7 @@
(self.context,), interfaces.IConfigurationStore)
for store in stores:
__traceback_info__ = repr(store)
+ store.root = self.root
store.dump(config)
return config
@@ -262,6 +266,8 @@
item = itemFactory()
item_store = interfaces.IConfigurationStore(item)
item_store.section = section
+ item_store.container = self.context
+ item_store.root = self.root
item_store.load(config)
# Note sends a ContainerModifiedEvent which would causes a config
# dump, overwriting the original file with partial information.
@@ -287,6 +293,7 @@
continue
item_store = interfaces.IConfigurationStore(item)
item_store.section = self.section_prefix + name.encode('UTF-8')
+ item_store.root = self.root
__traceback_info__ = item_store.section
item_store.dump(config)
return config
@@ -320,6 +327,7 @@
(self.context,), interfaces.IConfigurationStore)
for store in stores:
if not isinstance(store, self.__class__):
+ store.root = self.root
store.load(config)
zope.event.notify(
interfaces.ObjectConfigurationLoadedEvent(
@@ -355,6 +363,7 @@
(self.context,), interfaces.IConfigurationStore)
for store in stores:
__traceback_info__ = (fn, store)
+ store.root = self.root
store.dump(config)
# Write the configuration out.
with open(fn, 'w') as file:
Modified: cipher.configstore/trunk/src/cipher/configstore/interfaces.py
===================================================================
--- cipher.configstore/trunk/src/cipher/configstore/interfaces.py 2012-08-30 14:56:16 UTC (rev 127641)
+++ cipher.configstore/trunk/src/cipher/configstore/interfaces.py 2012-08-30 15:03:12 UTC (rev 127642)
@@ -36,6 +36,15 @@
description=u'The name of the section in the configuration.',
required=True)
+ container = zope.interface.Attribute(
+ 'The container in case the item under load will be added to one. '
+ 'Happens if CollectionConfigurationStore loads the object.')
+
+ root = zope.interface.Attribute(
+ "The root object being loaded by the ConfigurationStore hierarchy. "
+ "You'll need to set this attribute on the root ConfigurationStore "
+ "then it will get passed down the tree")
+
def load(config):
"""Load configuration and apply it to the object."""
More information about the checkins
mailing list