source:
products/quintagroup.plonegooglesitemaps/branches/sitemap_date/quintagroup/plonegooglesitemaps/utils.py
@
3501
Last change on this file since 3501 was 3501, checked in by potar, 12 years ago | |
---|---|
|
|
File size: 791 bytes |
Rev | Line | |
---|---|---|
[1593] | 1 | from urllib2 import urlopen |
[3501] | 2 | from urllib import quote as urlquote |
[3484] | 3 | from DateTime import DateTime |
[1593] | 4 | |
5 | from Globals import DevelopmentMode | |
[3163] | 6 | #from OFS.ObjectManager import BadRequestException |
[1593] | 7 | |
[2246] | 8 | from quintagroup.plonegooglesitemaps import config |
[1593] | 9 | |
[3152] | 10 | |
[1593] | 11 | def 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 | |
[3501] | 23 | g = urlopen('http://www.google.com/webmasters/tools/ping?sitemap=' + |
[3152] | 24 | sitemap_url) |
[3163] | 25 | g.read() |
[1593] | 26 | g.close() |
[1622] | 27 | |
[1593] | 28 | return 0 |
[3484] | 29 | |
30 | ||
31 | def dateTime(obj): | |
32 | """ Method gets modification date """ | |
33 | return DateTime(obj.ModificationDate()) |
Note: See TracBrowser
for help on using the repository browser.