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
Line 
1from urllib2 import urlopen
2from urllib  import quote as urlquote
3from DateTime import DateTime
4
5from Globals import DevelopmentMode
6#from OFS.ObjectManager import BadRequestException
7
8from quintagroup.plonegooglesitemaps import config
9
10
11def ping_google(url, sitemap_id):
12    """Ping sitemap to Google"""
13
14    resurl = url + "/" + sitemap_id
15
16    if DevelopmentMode or config.testing:
17        #prevent pinging in debug or testing mode
18        print "Pinged %s sitemap to Google" % resurl
19        return 0
20
21    sitemap_url = urlquote(resurl)
22
23    g = urlopen('http://www.google.com/webmasters/tools/ping?sitemap=' + \
24                sitemap_url)
25    g.read()
26    g.close()
27
28    return 0
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.