source: products/quintagroup.plonegooglesitemaps/tags/1.4.4/quintagroup/plonegooglesitemaps/utils.py

Last change on this file was 2412, checked in by mylan, 10 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
Line 
1from urllib2 import urlopen
2from urllib  import quote as urlquote
3
4from Globals import DevelopmentMode
5from OFS.ObjectManager import BadRequestException
6
7from quintagroup.plonegooglesitemaps import config
8
9def ping_google(url, sitemap_id):
10    """Ping sitemap to Google"""
11
12    resurl = url + "/" + sitemap_id
13
14    if DevelopmentMode or config.testing:
15        #prevent pinging in debug or testing mode
16        print "Pinged %s sitemap to Google" % resurl
17        return 0
18
19    sitemap_url = urlquote(resurl)
20
21    g = urlopen('http://www.google.com/webmasters/tools/ping?sitemap='+sitemap_url)
22    result = g.read()
23    g.close()
24
25    return 0
Note: See TracBrowser for help on using the repository browser.