source: products/quintagroup.plonegooglesitemaps/branches/sitemap_date/quintagroup/plonegooglesitemaps/utils.py @ 3484

Last change on this file since 3484 was 3484, checked in by potar, 8 years ago

added method which gets modification date

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