source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/utils.py @ 1623

Last change on this file since 1623 was 1623, checked in by mylan, 12 years ago

Fix URL for resubmission (pinging) of the new sitemap

  • Property svn:eol-style set to native
File size: 645 bytes
RevLine 
[1593]1from urllib2 import urlopen
2from urllib  import quote as urlquote
3
4from Globals import DevelopmentMode
5from OFS.ObjectManager import BadRequestException
6
7from quintagroup.plonegooglesitemaps.config import testing
8
9def ping_google(url, sitemap_id):
10    """Ping sitemap to Google"""
[1622]11
12    resurl = url + "/" + sitemap_id
13
14    if DevelopmentMode or testing:
15        #prevent pinging in debug or testing mode
16        print "Pinged %s sitemap to Google" % resurl
[1593]17        return 0
18
19    sitemap_url = urlquote(resurl)
[1622]20
[1623]21    g = urlopen('http://www.google.com/webmasters/tools/ping?sitemap='+sitemap_url)
[1593]22    result = g.read()
23    g.close()
[1622]24
[1593]25    return 0
Note: See TracBrowser for help on using the repository browser.