|
1 ### -*- coding: utf-8 -*- #################################################### |
|
2 ############################################################################## |
|
3 # |
|
4 # Copyright (c) 2008-2010 Thierry Florac <tflorac AT ulthar.net> |
|
5 # All Rights Reserved. |
|
6 # |
|
7 # This software is subject to the provisions of the Zope Public License, |
|
8 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|
9 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|
10 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
11 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|
12 # FOR A PARTICULAR PURPOSE. |
|
13 # |
|
14 ############################################################################## |
|
15 |
|
16 __docformat__ = "restructuredtext" |
|
17 |
|
18 # import standard packages |
|
19 |
|
20 # import Zope3 interfaces |
|
21 from zope.intid.interfaces import IIntIds |
|
22 |
|
23 # import local interfaces |
|
24 from ztfy.utils.interfaces import INewSiteManagerEvent |
|
25 |
|
26 # import Zope3 packages |
|
27 from zope.component import getUtility |
|
28 from zope.interface import implements |
|
29 from zope.location import locate |
|
30 |
|
31 # import local packages |
|
32 |
|
33 |
|
34 class NewSiteManagerEvent(object): |
|
35 """Event notified when a new site manager is created""" |
|
36 |
|
37 implements(INewSiteManagerEvent) |
|
38 |
|
39 def __init__(self, obj): |
|
40 self.object = obj |
|
41 |
|
42 |
|
43 def locateAndRegister(contained, parent, key, intids=None): |
|
44 locate(contained, parent) |
|
45 if intids is None: |
|
46 intids = getUtility(IIntIds) |
|
47 intids.register(contained) |
|
48 parent[key] = contained |