Changeset 54

Show
Ignore:
Timestamp:
11/22/05 07:33:20
Author:
crchemist
Message:

Added ability to genarate sitemap even googlesitemap_properties sheet is absent

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneGoogleSitemaps/trunk/skins/qPloneGoogleSitemaps/searchForGoogleSitemapObjects.py

    r53 r54  
    1515 
    1616catalog = getToolByName(context, 'portal_catalog') 
    17 props = getToolByName(context, 'portal_properties').googlesitemap_properties 
    18 res = catalog(path = path, 
    19               portal_type = props.portalTypes, 
    20               review_state = props.states, 
    21               ) 
     17try: 
     18    props = getToolByName(context, 'portal_properties').googlesitemap_properties 
     19    objects = catalog(path = path, 
     20                portal_type = props.portalTypes, 
     21                review_state = props.states, 
     22                ) 
     23except AttributeError: 
     24    # We are run without being properly installed, do default processing 
     25    return applyOperations(catalog(path = path, 
     26                                   review_state = ['published'], 
     27                                  ),[]) 
    2228 
    23 bl = props.blackout_list  
    24 result = list(res) 
    25 for cat in res: 
    26     for patt in bl: 
    27         match = str(cat.getId).find(patt) 
    28         if match <> -1: 
    29             try: 
    30                 result.remove(cat) 
    31             except: pass 
    32  
    33  
    34 pattern = props.getProperty('reg_exp') 
    35 r = applyOperations(result,pattern) 
    36  
    37 return r 
     29blackout_list = props.blackout_list 
     30return applyOperations([ob for ob in objects if not(ob.getId in blackout_list)], 
     31                    props.getProperty('reg_exp')) 
  • qPloneGoogleSitemaps/trunk/utils.py

    r53 r54  
    44import re 
    55import Products.qPloneGoogleSitemaps.config as config 
    6 from OFS.ObjectManager import BadRequestException 
     6from OFS.ObjectManager import BadRequestException# , AttributeError 
    77def ping_google(url): 
    88    """Ping sitemap to Google""" 
     
    2525def applyOperations(objects, operations): 
    2626    """Parse Operations """ 
    27     parse = re.compile('(.*?)/(.*?[^\\\])/(.*|.*?[^\\\])/(.*)') 
     27    parse = re.compile('(.*?)/(.*|.*?[^\\\])/(.*|.*?[^\\\])/(.*)') 
    2828    operations=[parse.match(op).groups() for op in operations] 
    2929    result={} 
     
    5050 
    5151    props = getToolByName(self,'portal_properties') 
    52     URLs = props.googlesitemap_properties.urls 
     52    try: 
     53        URLs = props.googlesitemap_properties.urls 
     54    except AttributeError: 
     55        URLs = [] 
    5356 
    5457    add_zope = re.compile('^/')