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

Last change on this file since 3507 was 3507, checked in by potar, 12 years ago

rewrote code (compatibility with Plone3.0)

  • Property svn:eol-style set to native
File size: 1.2 KB
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
7from Products.CMFCore.utils import getToolByName
8
9from quintagroup.plonegooglesitemaps import config
10
11
12def ping_google(url, sitemap_id):
13    """Ping sitemap to Google"""
14
15    resurl = url + "/" + sitemap_id
16
17    if DevelopmentMode or config.testing:
18        #prevent pinging in debug or testing mode
19        print "Pinged %s sitemap to Google" % resurl
20        return 0
21
22    sitemap_url = urlquote(resurl)
23
24    g = urlopen('http://www.google.com/webmasters/tools/ping?sitemap=' +
25                sitemap_url)
26    g.read()
27    g.close()
28
29    return 0
30
31
32def getDefaultPage(obj):
33    """ Method gets default page for object (folderish) """
34    plone_tool = getToolByName(obj, 'plone_utils')
35    return plone_tool.getDefaultPage(obj)
36
37
38def isDefaultPage(obj):
39    """ If object is default page then return True"""
40    plone_tool = getToolByName(obj, 'plone_utils')
41    return plone_tool.isDefaultPage(obj)
42
43
44def dateTime(obj):
45    """ Method gets modification date """
46    return DateTime(obj.ModificationDate())
Note: See TracBrowser for help on using the repository browser.