source: products/qPloneGoogleSitemaps/trunk/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
RevLine 
[414]1from zope.component import adapter
2from Products.CMFCore.utils import getToolByName
[448]3#from Products.qPloneGoogleSitemaps.events import AfterTransitionEvent
[414]4from Products.qPloneGoogleSitemaps.interfaces import IAfterTransitionEvent
5from Products.qPloneGoogleSitemaps.utils import ping_google
6
[448]7@adapter(IAfterTransitionEvent)
8def pingGoogle(event):
[635]9    tr_id = getattr(event.transition,'id','')
10    if not tr_id:
11        # object under creation
12        return 0
13
[414]14    object = event.object
[448]15    catalog = getToolByName(object, 'portal_catalog')
[443]16
[448]17    sitemaps = [b.getObject() for b in catalog(portal_type='Sitemap')]
18    if sitemaps:
19        plone_home = getToolByName(object, 'portal_url').getPortalObject().absolute_url()
[635]20        wftrans_name = "%s#%s" % (event.workflow.id, tr_id)
[454]21        obj_ptype = object.portal_type
[448]22        for sm in sitemaps:
[454]23            if wftrans_name in sm.getPingTransitions() \
24               and obj_ptype in sm.getPortalTypes():
[448]25                ping_google(plone_home, sm.id)
[414]26    return 0
Note: See TracBrowser for help on using the repository browser.