Ignore:
Timestamp:
Mar 12, 2010 2:08:40 PM (14 years ago)
Author:
mylan
Message:

#166: Force usage ISEOConfigletSchema adapter for getting seo properties

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/branches/refactoring2.3.0/quintagroup/seoptimizer/browser/views.py

    r1831 r1900  
    120120        """ 
    121121        result = [] 
    122         context = aq_inner(self.context) 
    123122        if self.gseo: 
    124             custom_meta_tags = self.gseo.default_custom_metatags 
    125             for tag in custom_meta_tags: 
     123            for tag in self.gseo.default_custom_metatags: 
    126124                name_value = tag.split(SEPERATOR) 
    127125                if name_value[0]: 
     
    141139    """ 
    142140    template = ViewPageTemplateFile('templates/seo_context_properties.pt') 
     141 
     142    def __init__(self, *args, **kwargs): 
     143        super(SEOContextPropertiesView, self).__init__(*args, **kwargs) 
     144        self.pps = queryMultiAdapter((self.context, self.request), 
     145                                     name="plone_portal_state") 
     146        self.gseo = queryAdapter(self.pps.portal(), ISEOConfigletSchema) 
     147 
    143148 
    144149    def test( self, condition, first, second ): 
     
    231236        """ Update seo custom metatags properties. 
    232237        """ 
    233         context = aq_inner(self.context) 
    234         site_properties = getToolByName(context, 'portal_properties') 
    235238        globalCustomMetaTags = [] 
    236         if hasattr(site_properties, 'seo_properties'): 
    237             custom_meta_tags = getattr(site_properties.seo_properties, 'default_custom_metatags', []) 
     239        if self.gseo: 
     240            custom_meta_tags = self.gseo.default_custom_metatags 
    238241            for tag in custom_meta_tags: 
    239242                name_value = tag.split(SEPERATOR) 
    240243                if name_value[0]: 
    241                     globalCustomMetaTags.append({'meta_name'    : name_value[0], 
    242                                                  'meta_content' : len(name_value) == 1 and '' or name_value[1]}) 
     244                    globalCustomMetaTags.append( 
     245                        {'meta_name' : name_value[0], 
     246                         'meta_content' : len(name_value) == 1 and '' or name_value[1]}) 
    243247        for tag in custommetatags: 
    244248            meta_name, meta_content = tag['meta_name'], tag['meta_content'] 
    245249            if meta_name: 
    246                 if not [gmt for gmt in globalCustomMetaTags if (gmt['meta_name']==meta_name and gmt['meta_content']==meta_content)]: 
     250                if not [gmt for gmt in globalCustomMetaTags \ 
     251                        if (gmt['meta_name']==meta_name and gmt['meta_content']==meta_content)]: 
    247252                    self.setProperty('%s%s' % (PROP_CUSTOM_PREFIX, meta_name), meta_content) 
    248253 
Note: See TracChangeset for help on using the changeset viewer.