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

Last change on this file since 3399 was 3163, checked in by zidane, 13 years ago

fixes pyflakes and pylint

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