Index: qPloneGoogleSitemaps/branches/contenttype/Extensions/ping_googlesitemap.py
===================================================================
--- qPloneGoogleSitemaps/branches/contenttype/Extensions/ping_googlesitemap.py	(revision 412)
+++ qPloneGoogleSitemaps/branches/contenttype/Extensions/ping_googlesitemap.py	(revision 414)
@@ -1,7 +1,8 @@
-from Products.qPloneGoogleSitemaps.utils import ping_google
-from Products.CMFCore.utils import getToolByName
-def  ping_googlesitemap(state_change):
-    """ping sitemap to Google when document has published"""
-    plone_home = getToolByName(state_change.object, 'portal_url').getPortalObject().absolute_url()
-    ping_google(plone_home)
-    return 0 
+from zope.event import notify
+from Products.qPloneGoogleSitemaps.events import AfterTransitionEvent
+
+def pingGoogleSitemap(stch):
+    notify(AfterTransitionEvent(stch.object,
+           stch.workflow, stch.old_state, stch.new_state,
+           stch.transition, stch.status, stch.kwargs))
+    return 0
Index: qPloneGoogleSitemaps/branches/contenttype/__init__.py
===================================================================
--- qPloneGoogleSitemaps/branches/contenttype/__init__.py	(revision 412)
+++ qPloneGoogleSitemaps/branches/contenttype/__init__.py	(revision 414)
@@ -14,5 +14,5 @@
 
 from Products.Archetypes import atapi
-from Products.CMFCore import utils
+from Products.CMFCore.utils import ContentInit
 from Products.CMFCore.permissions import setDefaultRoles
 
@@ -52,5 +52,5 @@
 
     for atype, constructor in zip(content_types, constructors):
-        utils.ContentInit('%s: %s' % (config.PROJECTNAME, atype.portal_type),
+        ContentInit('%s: %s' % (config.PROJECTNAME, atype.portal_type),
             content_types      = (atype,),
             permission         = config.ADD_PERMISSIONS[atype.portal_type],
Index: qPloneGoogleSitemaps/branches/contenttype/config.py
===================================================================
--- qPloneGoogleSitemaps/branches/contenttype/config.py	(revision 412)
+++ qPloneGoogleSitemaps/branches/contenttype/config.py	(revision 414)
@@ -9,3 +9,14 @@
 }
 
-ping_googlesitemap = 'ping_googlesitemap'
+SITEMAPS_LIST = ['content','mobile','news']
+
+ping_googlesitemap = 'pingGoogleSitemap'
+
+AVAILABLE_WF_SCRIPTS = [ping_googlesitemap, '']
+
+try:
+    from Products.DCWorkflow.events import AfterTransitionEvent
+except ImportError:
+    IS_PLONE_3 = False
+else:
+    IS_PLONE_3 = True
Index: qPloneGoogleSitemaps/branches/contenttype/configure.zcml
===================================================================
--- qPloneGoogleSitemaps/branches/contenttype/configure.zcml	(revision 412)
+++ qPloneGoogleSitemaps/branches/contenttype/configure.zcml	(revision 414)
@@ -20,3 +20,5 @@
     <!-- -*- extra stuff goes here -*- -->
 
+    <subscriber handler=".handlers.pingGoogle"/>
+
 </configure>
Index: qPloneGoogleSitemaps/branches/contenttype/content/sitemap.py
===================================================================
--- qPloneGoogleSitemaps/branches/contenttype/content/sitemap.py	(revision 412)
+++ qPloneGoogleSitemaps/branches/contenttype/content/sitemap.py	(revision 414)
@@ -11,8 +11,5 @@
 from Products.qPloneGoogleSitemaps import qPloneGoogleSitemapsMessageFactory as _
 from Products.qPloneGoogleSitemaps.interfaces import ISitemap
-from Products.qPloneGoogleSitemaps.config import PROJECTNAME
-from Products.qPloneGoogleSitemaps.config import ping_googlesitemap
-
-SITEMAPS_LIST = ['content','mobile','news']
+from Products.qPloneGoogleSitemaps.config import * 
 
 SitemapSchema = schemata.ATContentTypeSchema.copy() + atapi.Schema((
@@ -125,4 +122,5 @@
 SitemapSchema['id'].widget.ignore_visible_ids = True
 SitemapSchema['title'].storage = atapi.AnnotationStorage()
+SitemapSchema['title'].required=False
 SitemapSchema['title'].widget.visible = {'edit':'invisible', 'view':'invisible'}
 SitemapSchema['description'].storage = atapi.AnnotationStorage()
@@ -162,5 +160,5 @@
                 continue
             for wf_tr in wf.transitions.values():
-                if wf_tr.after_script_name in ['', 'ping_googlesitemap']:
+                if wf_tr.after_script_name in AVAILABLE_WF_SCRIPTS:
                     wf_trans.append(("%s#%s" % (wf_id,wf_tr.id),
                         "%s : %s (%s)" % (wf_id,wf_tr.id,wf_tr.title_or_id())))
@@ -170,38 +168,42 @@
         """Add 'Ping sitemap' afterscript for selected workflow transitions.
         """
-        pw = getToolByName(self, 'portal_workflow')
-        transmap = {}
-        for key in value:
-            if key.find('#')>0:
-                ids = key.split('#')
-                wfid = ids[0]
-                if not wfid in transmap.keys():
-                    transmap[wfid]=[]
-                transmap[wfid].append(ids[1])
-        for wfid in transmap.keys():
-            workflow = pw.getWorkflowById(wfid)
-            if ping_googlesitemap not in workflow.scripts.objectIds():
-                workflow.scripts.manage_addProduct['ExternalMethod'].manage_addExternalMethod(
-                    ping_googlesitemap,
-                    'Ping sitemap',
-                    'qPloneGoogleSitemaps.ping_googlesitemap',
-                    ping_googlesitemap)
-            transitions_set = transmap[wfid]
-            for transition in workflow.transitions.values():
-                trid = transition.id
-                tras = transition.after_script_name
-                if (tras == '') and (trid in transitions_set):
-                    #set
-                    after_script = ping_googlesitemap
-                elif (tras == ping_googlesitemap) and not (trid in transitions_set):
-                    #reset
-                    after_script = ''
-                else:
-                    #avoid properties set
-                    continue
-                transition.setProperties(title=transition.title,
-                    new_state_id=transition.new_state_id,
-                    after_script_name=after_script,
-                    actbox_name=transition.actbox_name)
+        self.getField('pingTransitions').set(self, value)
+        if not IS_PLONE_3:
+            # Update Workflow if needed
+            pw = getToolByName(self, 'portal_workflow')
+            #ping_googlesitemap = PING_EMETHODS_MAP[self.getSitemapType()]
+            transmap = {}
+            for key in value:
+                if key.find('#')>0:
+                    ids = key.split('#')
+                    wfid = ids[0]
+                    if not wfid in transmap.keys():
+                        transmap[wfid]=[]
+                    transmap[wfid].append(ids[1])
+            for wfid in transmap.keys():
+                workflow = pw.getWorkflowById(wfid)
+                if ping_googlesitemap not in workflow.scripts.objectIds():
+                    workflow.scripts.manage_addProduct['ExternalMethod'].manage_addExternalMethod(
+                        ping_googlesitemap,
+                        'Ping sitemap',
+                        'qPloneGoogleSitemaps.ping_googlesitemap',
+                        ping_googlesitemap)
+                transitions_set = transmap[wfid]
+                for transition in workflow.transitions.values():
+                    trid = transition.id
+                    tras = transition.after_script_name
+                    if (tras == '') and (trid in transitions_set):
+                        #set
+                        after_script = ping_googlesitemap
+                    elif (tras == ping_googlesitemap) and not (trid in transitions_set):
+                        #reset
+                        after_script = ''
+                    else:
+                        #avoid properties set
+                        continue
+                    transition.setProperties(title=transition.title,
+                        new_state_id=transition.new_state_id,
+                        after_script_name=after_script,
+                        actbox_name=transition.actbox_name)
 
 atapi.registerType(Sitemap, PROJECTNAME)
Index: qPloneGoogleSitemaps/branches/contenttype/events.py
===================================================================
--- qPloneGoogleSitemaps/branches/contenttype/events.py	(revision 414)
+++ qPloneGoogleSitemaps/branches/contenttype/events.py	(revision 414)
@@ -0,0 +1,22 @@
+try:
+    from Products.DCWorkflow.events import AfterTransitionEvent
+except ImportError:
+    # Copy AfterTransitionEvent from Plone-3/Products.DCWorkflow.events
+    from zope.interface import implements
+    from zope.app.event.objectevent import ObjectEvent
+    from Products.qPloneGoogleSitemaps.interfaces import *
+
+    class TransitionEvent(ObjectEvent):
+        implements(ITransitionEvent)
+
+        def __init__(self, obj, workflow, old_state, new_state, transition, status, kwargs):
+            ObjectEvent.__init__(self, obj)
+            self.workflow = workflow
+            self.old_state = old_state
+            self.new_state = new_state
+            self.transition = transition
+            self.status = status
+            self.kwargs = kwargs
+
+    class AfterTransitionEvent(TransitionEvent):
+        implements(IAfterTransitionEvent)
Index: qPloneGoogleSitemaps/branches/contenttype/handlers.py
===================================================================
--- qPloneGoogleSitemaps/branches/contenttype/handlers.py	(revision 414)
+++ qPloneGoogleSitemaps/branches/contenttype/handlers.py	(revision 414)
@@ -0,0 +1,32 @@
+from urllib2 import urlopen
+from urllib  import quote as urlquote
+
+from zope.component import adapter
+from Products.CMFCore.utils import getToolByName
+from Products.qPloneGoogleSitemaps.events import AfterTransitionEvent
+from Products.qPloneGoogleSitemaps.interfaces import IAfterTransitionEvent
+from Products.qPloneGoogleSitemaps.utils import ping_google
+
+def pingByType(event, smtype):
+    object = event.object
+    catalog = getToolByName(object, 'portal_catalog')
+
+    csm = None
+    for brain in catalog(portal_type='Sitemap'):
+        smobj = brain.getObject()
+        if smobj.getSitemapType() == smtype:
+            csm = smobj
+            break
+    if csm:
+        wftrans_name = "%s#%s" % (event.workflow.id, event.transition.id)
+        if wftrans_name in csm.getPingTransitions():
+            plone_home = getToolByName(object, 'portal_url').getPortalObject().absolute_url()
+            ping_google(plone_home, csm.id)
+            print "Pinged %s sitemap to google" % smtype
+
+
+@adapter(IAfterTransitionEvent)
+def pingGoogle(event):
+    for smtype in ['content', 'mobile', 'news']:
+        pingByType(event, smtype)
+    return 0
Index: qPloneGoogleSitemaps/branches/contenttype/interfaces.py
===================================================================
--- qPloneGoogleSitemaps/branches/contenttype/interfaces.py	(revision 412)
+++ qPloneGoogleSitemaps/branches/contenttype/interfaces.py	(revision 414)
@@ -11,2 +11,26 @@
 class ISitemap(Interface):
     """Search engine Sitemap content type"""
+
+try:
+    from Products.DCWorkflow.interfaces import IAfterTransitionEvent
+except ImportError:
+    # Copy IAfterTransitionEvent from Plone-3/Products.DCWorkflow.interfaces
+    from zope.interface import Interface, Attribute
+    from zope.app.event.interfaces import IObjectEvent
+
+    class ITransitionEvent(IObjectEvent):
+        """An event that's fired upon a workflow transition.
+        """
+
+        workflow = Attribute(u"The workflow definition triggering the transition")
+        old_state = Attribute(u"The state definition of the workflow state before the transition")
+        new_state = Attribute(u"The state definition of the workflow state before after transition")
+        transition = Attribute(u"The transition definition taking place. "
+                                "May be None if this is the 'transition' to the initial state.")
+        status = Attribute(u"The status dict of the object.")
+        kwargs = Attribute(u"Any keyword arguments passed to doActionFor() when the transition was invoked")
+
+    class IAfterTransitionEvent(ITransitionEvent):
+
+        """An event that's fired after a workflow transition.
+        """
Index: qPloneGoogleSitemaps/branches/contenttype/utils.py
===================================================================
--- qPloneGoogleSitemaps/branches/contenttype/utils.py	(revision 412)
+++ qPloneGoogleSitemaps/branches/contenttype/utils.py	(revision 414)
@@ -5,7 +5,7 @@
 import Products.qPloneGoogleSitemaps.config as config
 from OFS.ObjectManager import BadRequestException
-def ping_google(url):
+def ping_google(url, sitemap_id):
     """Ping sitemap to Google"""
-    sitemap_url = urlquote(url + "/google-sitemaps")
+    sitemap_url = urlquote(url + "/" + sitemap_id)
     g = urlopen('http://www.google.com/webmasters/sitemaps/ping?sitemap='+sitemap_url)
     result = g.read()
@@ -64,45 +64,45 @@
 
 """workflows & co"""
-def getWorkflowTransitions(self,workflow_id):
-    pw = getToolByName(self,'portal_workflow')
-    wf = pw.getWorkflowById(workflow_id)
-    if not wf:
-        return None
-    return wf.transitions.values()
+#def getWorkflowTransitions(self,workflow_id):
+    #pw = getToolByName(self,'portal_workflow')
+    #wf = pw.getWorkflowById(workflow_id)
+    #if not wf:
+        #return None
+    #return wf.transitions.values()
 
-def setWorkflowTransitions(self,transitions):
-    """set workflow transitions properties"""
-    portal_workflow = getToolByName(self, 'portal_workflow')
-    transmap = {}
-    for key in transitions:
-        if key.find('#')>0:
-            ids = key.split('#')
-            wfid = ids[0]
-            if not wfid in transmap.keys():
-                transmap[wfid]=[]
-            transmap[wfid].append(ids[1])
-    for wfid in transmap.keys():
-        workflow = portal_workflow.getWorkflowById(wfid)
-        if config.ping_googlesitemap not in workflow.scripts.objectIds():
-            workflow.scripts.manage_addProduct['ExternalMethod'].manage_addExternalMethod(
-                                config.ping_googlesitemap,
-                                'Ping sitemap',
-                                'qPloneGoogleSitemaps.ping_googlesitemap',
-                                config.ping_googlesitemap)
-        transitions_set = transmap[wfid]
-        for transition in workflow.transitions.values():
-            trid = transition.id
-            tras = transition.after_script_name
-            if (tras == '') and (trid in transitions_set):
-                #set
-                after_script = config.ping_googlesitemap
-            elif (tras == config.ping_googlesitemap) and not (trid in transitions_set):
-                #reset
-                after_script = ''
-            else:
-                #avoid properties set
-                continue
-            transition.setProperties(title=transition.title,
-                                     new_state_id=transition.new_state_id,
-                                     after_script_name=after_script,
-                                     actbox_name=transition.actbox_name)
+#def setWorkflowTransitions(self,transitions):
+    #"""set workflow transitions properties"""
+    #portal_workflow = getToolByName(self, 'portal_workflow')
+    #transmap = {}
+    #for key in transitions:
+        #if key.find('#')>0:
+            #ids = key.split('#')
+            #wfid = ids[0]
+            #if not wfid in transmap.keys():
+                #transmap[wfid]=[]
+            #transmap[wfid].append(ids[1])
+    #for wfid in transmap.keys():
+        #workflow = portal_workflow.getWorkflowById(wfid)
+        #if config.ping_googlesitemap not in workflow.scripts.objectIds():
+            #workflow.scripts.manage_addProduct['ExternalMethod'].manage_addExternalMethod(
+                                #config.ping_googlesitemap,
+                                #'Ping sitemap',
+                                #'qPloneGoogleSitemaps.ping_googlesitemap',
+                                #config.ping_googlesitemap)
+        #transitions_set = transmap[wfid]
+        #for transition in workflow.transitions.values():
+            #trid = transition.id
+            #tras = transition.after_script_name
+            #if (tras == '') and (trid in transitions_set):
+                ##set
+                #after_script = config.ping_googlesitemap
+            #elif (tras == config.ping_googlesitemap) and not (trid in transitions_set):
+                ##reset
+                #after_script = ''
+            #else:
+                ##avoid properties set
+                #continue
+            #transition.setProperties(title=transition.title,
+                                     #new_state_id=transition.new_state_id,
+                                     #after_script_name=after_script,
+                                     #actbox_name=transition.actbox_name)
