Changeset 1726 in products


Ignore:
Timestamp:
Feb 12, 2010 1:06:33 PM (11 years ago)
Author:
mylan
Message:

Updated getting canonical_path data for sitemap record (use ICacnonicalPath adapter as fallback)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/browser/utils.py

    r1593 r1726  
    11import re 
     2from zope.component import queryAdapter 
    23 
    34from DateTime import DateTime 
     5from Missing import MV as Missing_Value 
     6from Products.CMFCore.utils import getToolByName 
    47 
    5 from Products.CMFCore.utils import getToolByName 
     8from quintagroup.canonicalpath.interfaces import ICanonicalPath 
    69import quintagroup.plonegooglesitemaps.config as config 
    710 
     
    912ADD_PLONE = re.compile('^[^http://|https://|\\\]') 
    1013OPERATIONS_PARSE = re.compile(r"(.?[^\\])/(.*[^\\]|)/(.*[^\\]|)/") 
     14_marker = [] 
    1115 
    1216def searchAndReplace(string, what, with): 
     
    2125    result = {} 
    2226    for ob in objects: 
     27        url = _marker 
    2328        if ob.has_key('canonical_path'): 
    2429            url = ob.canonical_path 
    25         else: 
    26             url = '/'+'/'.join(ob.getPath().split('/')[2:]) 
     30        if url in [Missing_Value, _marker]: 
     31            cpath = queryAdapter(ob.getObject(), ICanonicalPath) 
     32            url = cpath.canonical_path() 
    2733        for operator, what, with in operations: 
    2834            url = OPERATORS[operator](url, what, with.replace("\\", "")) 
Note: See TracChangeset for help on using the changeset viewer.