# HG changeset patch # User Thierry Florac # Date 1283924741 -7200 # Node ID c9861a9a860652859c2c37bf85020c440ea4eee2 # Parent e858d602a08971fc1fc9408ea9053e01a939bceb Add 'locateAndRegister' facility function diff -r e858d602a089 -r c9861a9a8606 ztfy/utils/site.py --- a/ztfy/utils/site.py Sat Aug 28 02:42:28 2010 +0200 +++ b/ztfy/utils/site.py Wed Sep 08 07:45:41 2010 +0200 @@ -18,12 +18,15 @@ # import standard packages # import Zope3 interfaces +from zope.app.intid.interfaces import IIntIds # import local interfaces from interfaces import INewSiteManagerEvent # import Zope3 packages +from zope.app import zapi from zope.interface import implements +from zope.location import locate # import local packages @@ -35,3 +38,11 @@ def __init__(self, obj): self.object = obj + + +def locateAndRegister(contained, parent, key, intids=None): + locate(contained, parent) + if intids is None: + intids = zapi.getUtility(IIntIds) + intids.register(contained) + parent[key] = contained