Skip to content

Commit

Permalink
We actually need this.
Browse files Browse the repository at this point in the history
  • Loading branch information
thefunny42 committed Sep 14, 2016
1 parent 2926564 commit e35ffbb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/grokcore/site/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,22 @@
@grokcore.component.subscribe(Site, IObjectAddedEvent)
def addSiteHandler(site, event):
"""Add a local site manager to a Grok site object upon its creation.
Grok registers this function so that it gets called each time a
`grokcore.site.Site` instance is added to a container. It creates
a local site manager and installs it on the newly created site.
"""
if event.oldParent is not None:
return
sitemanager = LocalSiteManager(site)
# LocalSiteManager creates the 'default' folder in its __init__.
# It's not needed anymore in new versions of Zope 3, therefore we
# remove it
del sitemanager['default']
site.setSiteManager(sitemanager)


@grokcore.component.subscribe(Site, IObjectRemovedEvent)
def removeSiteHandler(site, event):
"""Cleanup a after a site was removed.
"""
if event.newParent is not None:
# Please note that the code for moving a site is properly implemented
# inside zope.site.
return
local = site.getSiteManager()
parent = _findNextSiteManager(site)
if parent is not None:
Expand Down

0 comments on commit e35ffbb

Please sign in to comment.