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

Last change on this file was 635, checked in by chervol, 13 years ago

retagging

  • Property svn:eol-style set to native
File size: 1016 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    tr_id = getattr(event.transition,'id','')
10    if not tr_id:
11        # object under creation
12        return 0
13
14    object = event.object
15    catalog = getToolByName(object, 'portal_catalog')
16
17    sitemaps = [b.getObject() for b in catalog(portal_type='Sitemap')]
18    if sitemaps:
19        plone_home = getToolByName(object, 'portal_url').getPortalObject().absolute_url()
20        wftrans_name = "%s#%s" % (event.workflow.id, tr_id)
21        obj_ptype = object.portal_type
22        for sm in sitemaps:
23            if wftrans_name in sm.getPingTransitions() \
24               and obj_ptype in sm.getPortalTypes():
25                ping_google(plone_home, sm.id)
26    return 0
Note: See TracBrowser for help on using the repository browser.