Ignore:
Timestamp:
Dec 18, 2009 2:06:24 PM (14 years ago)
Author:
liebster
Message:

Cleaned code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.seoptimizer/trunk/quintagroup/seoptimizer/browser/views.py

    r1461 r1462  
    310310        """ 
    311311        return condition and first or second  
     312       
     313    def setProperty(self, property, value, type='string'): 
     314        context = aq_inner(self.context) 
     315        if context.hasProperty(property): 
     316            context.manage_changeProperties({property: value}) 
     317        else: 
     318            context.manage_addProperty(property, value, type) 
    312319 
    313320    def manageSEOProps(self, **kw): 
     
    328335        if delete_list: context.manage_delProperties(delete_list) 
    329336 
    330     def delSEOCustomMetaTags(self): 
     337    def setSEOCustomMetaTags(self, custommetatags): 
     338        context = aq_inner(self.context) 
     339        for k, v in custommetatags.items(): 
     340            self.setProperty('%s%s' % (PROP_CUSTOM_PREFIX, meta_name), meta_content)    
     341 
     342    def delAllSEOCustomMetaTagsByNames(self): 
    331343        context = self.context 
    332344        delete_list = [] 
     
    336348        if delete_list: context.manage_delProperties(delete_list)         
    337349 
    338     def delSEOCustomMetaTag(self, custommetatag): 
     350    def delSEOCustomMetaTagByName(self, custommetatagname): 
    339351        context = self.context 
    340         if context.hasProperty(custommetatag): 
    341             context.manage_delProperties(custommetatag) 
    342        
    343     def manageSEOCustomMetaTags(self, **kw): 
    344         context = aq_inner(self.context) 
    345         if kw.has_key('seo_custommetatags_override'): 
    346             if kw.get('seo_custommetatags_override'): 
    347                 custommetatags = kw.get('seo_custommetatags', {}) 
    348                 self.updateSEOCustomMetaTags(custommetatags) 
    349             else: 
    350                 self.delSEOCustomMetaTags() 
    351         elif kw.get('seo_custommetatags'): 
    352             self.delSEOCustomMetaTags() 
     352        seo_custom_prop = PROP_CUSTOM_PREFIX + custommetatagname 
     353        if context.hasProperty(seo_custom_prop): 
     354            context.manage_delProperties([seo_custom__prop]) 
    353355 
    354356    def updateSEOCustomMetaTags(self, custommetatags): 
     
    366368   
    367369        for tag in custommetatags: 
     370            metalist = [] 
    368371            meta_name, meta_content = tag['meta_name'], tag['meta_content'] 
    369372            if meta_name: 
    370373                if not [gmt for gmt in globalCustomMetaTags if (gmt['meta_name']==meta_name and gmt['meta_content']==meta_content)]: 
    371                     self.setProperty('%s%s' % (PROP_CUSTOM_PREFIX, meta_name), meta_content) 
    372  
    373     def setSEOCustomMetaTags(self, custommetatags=None): 
    374         context = aq_inner(self.context) 
    375         if custommetatags is not None: 
    376             if len(custommetatags): 
    377                 self.delSEOCustomMetaTags() 
     374                    metalist.append(tag) 
     375                self.setSEOCustomMetaTags(metalist) 
     376       
     377    def manageSEOCustomMetaTags(self, **kw): 
     378        context = aq_inner(self.context) 
     379        if kw.has_key('seo_custommetatags_override'): 
     380            if kw.get('seo_custommetatags_override'): 
     381                custommetatags = kw.get('seo_custommetatags', {}) 
     382                self.updateSEOCustomMetaTags(custommetatags) 
    378383            else: 
    379                 for k, v in custommetatags.items(): 
    380                     self.setProperty('%s%s' % (PROP_CUSTOM_PREFIX, meta_name), meta_content)    
    381        
    382     def setProperty(self, property, value, type='string'): 
    383         context = aq_inner(self.context) 
    384         if context.hasProperty(property): 
    385             context.manage_changeProperties({property: value}) 
    386         else: 
    387             context.manage_addProperty(property, value, type) 
     384                self.delAllSEOCustomMetaTagsByNames() 
     385        elif kw.get('seo_custommetatags'): 
     386            self.delAllSEOCustomMetaTagsByNames() 
    388387 
    389388    def __call__( self ): 
Note: See TracChangeset for help on using the changeset viewer.