source: products/quintagroup.plonegooglesitemaps/branches/1.7.1/quintagroup/plonegooglesitemaps/utils.py

Last change on this file was 3163, checked in by zidane, 10 years ago

fixes pyflakes and pylint

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