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

Last change on this file since 2412 was 2412, checked in by mylan, 14 years ago

#131: Remove needless add/remove news-sitemaps related schema adapter registration methods

  • Property svn:eol-style set to native
File size: 644 bytes
RevLine 
[1593]1from urllib2 import urlopen
2from urllib  import quote as urlquote
3
4from Globals import DevelopmentMode
5from OFS.ObjectManager import BadRequestException
6
[2246]7from quintagroup.plonegooglesitemaps import config
[1593]8
9def ping_google(url, sitemap_id):
10    """Ping sitemap to Google"""
[1622]11
12    resurl = url + "/" + sitemap_id
13
[2246]14    if DevelopmentMode or config.testing:
[1622]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.