[Checkins] SVN: zope.generic/trunk/src/zope/generic/ add new
factory method createAndNotifyObject
Dominik Huber
dominik.huber at perse.ch
Tue May 23 12:31:49 EDT 2006
Log message for revision 68257:
add new factory method createAndNotifyObject
fix bugs
Changed:
U zope.generic/trunk/src/zope/generic/configuration/adapter.py
U zope.generic/trunk/src/zope/generic/configuration/base.py
U zope.generic/trunk/src/zope/generic/factory/api.py
-=-
Modified: zope.generic/trunk/src/zope/generic/configuration/adapter.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/adapter.py 2006-05-23 16:23:39 UTC (rev 68256)
+++ zope.generic/trunk/src/zope/generic/configuration/adapter.py 2006-05-23 16:31:48 UTC (rev 68257)
@@ -163,7 +163,10 @@
# notify setting
parent = self.__parent__
if ILocation.providedBy(parent) and parent.__parent__ is not None:
- data = configuratonToDict(value, all=True)
+ if isinstance(value, dict):
+ data = value
+ else:
+ data = configuratonToDict(value, all=True)
notify(ObjectConfiguredEvent(parent,
Configuration(keyface, data)))
Modified: zope.generic/trunk/src/zope/generic/configuration/base.py
===================================================================
--- zope.generic/trunk/src/zope/generic/configuration/base.py 2006-05-23 16:23:39 UTC (rev 68256)
+++ zope.generic/trunk/src/zope/generic/configuration/base.py 2006-05-23 16:31:48 UTC (rev 68257)
@@ -72,6 +72,7 @@
def prepareData(__keyface__, data):
"""Nested configuration support."""
missedArguments = []
+ relevant_data = {}
for name in __keyface__:
# forget missing but none-required
if name not in data:
@@ -81,7 +82,7 @@
try:
subdata = subData(name, data)
if subdata or field.required is True:
- data[name] = createConfiguration(field.schema, subData(name, data))
+ relevant_data[name] = createConfiguration(field.schema, subData(name, data))
continue
except:
@@ -89,11 +90,13 @@
if field.required is True:
missedArguments.append(name)
+ else:
+ relevant_data[name] = data[name]
if missedArguments:
raise TypeError("__init__ requires '%s' of '%s'." % (', '.join(missedArguments), __keyface__.__name__))
- return data
+ return relevant_data
Modified: zope.generic/trunk/src/zope/generic/factory/api.py
===================================================================
--- zope.generic/trunk/src/zope/generic/factory/api.py 2006-05-23 16:23:39 UTC (rev 68256)
+++ zope.generic/trunk/src/zope/generic/factory/api.py 2006-05-23 16:31:48 UTC (rev 68257)
@@ -19,6 +19,8 @@
__docformat__ = 'restructuredtext'
from zope import component
+from zope.event import notify
+from zope.lifecycleevent import ObjectCreatedEvent
from zope.generic.informationprovider.api import getInformationProvider
from zope.generic.informationprovider.api import queryInformation
@@ -29,13 +31,20 @@
-
def createObject(keyface, *pos, **kws):
"""Create an instance of a logical type using the type marker."""
return component.createObject(toDottedName(keyface), *pos, **kws)
+def createAndNotifyObject(keyface, *pos, **kws):
+ """Create an instance of a logical type using the type marker."""
+ obj = component.createObject(toDottedName(keyface), *pos, **kws)
+ notify(ObjectCreatedEvent(obj))
+ return obj
+
+
+
def createParameter(keyface):
"""Evaluate initializer parameters."""
provider = getInformationProvider(keyface)
More information about the Checkins
mailing list