source: products/qPloneGoogleSitemaps/tags/0.8/handlers.py

Last change on this file was 458, checked in by fenix, 13 years ago

qPloneResolveUID import

  • Property svn:eol-style set to native
File size: 916 bytes
Line 
1from zope.component import adapter
2from Products.CMFCore.utils import getToolByName
3#from Products.qPloneGoogleSitemaps.events import AfterTransitionEvent
4from Products.qPloneGoogleSitemaps.interfaces import IAfterTransitionEvent
5from Products.qPloneGoogleSitemaps.utils import ping_google
6
7@adapter(IAfterTransitionEvent)
8def pingGoogle(event):
9    object = event.object
10    catalog = getToolByName(object, 'portal_catalog')
11
12    sitemaps = [b.getObject() for b in catalog(portal_type='Sitemap')]
13    if sitemaps:
14        plone_home = getToolByName(object, 'portal_url').getPortalObject().absolute_url()
15        wftrans_name = "%s#%s" % (event.workflow.id, event.transition.id)
16        obj_ptype = object.portal_type
17        for sm in sitemaps:
18            if wftrans_name in sm.getPingTransitions() \
19               and obj_ptype in sm.getPortalTypes():
20                ping_google(plone_home, sm.id)
21    return 0
Note: See TracBrowser for help on using the repository browser.