Skip to content

Commit

Permalink
Use safe_hasattr instead hasattr
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Mar 4, 2016
1 parent fa78b31 commit e3bd950
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/brasil/gov/agenda/content/agendadiaria.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def SearchableText_AgendaDiaria(obj):
SearchableText.append(obj.location)
# Alteracao da agenda
update = obj.update
if hasattr(update, 'output'):
if safe_hasattr(update, 'output'):
update = update.output
SearchableText.append(update)
return ' '.join([text for text in SearchableText
Expand Down Expand Up @@ -188,7 +188,7 @@ def end_date(obj):
def exclude_from_nav(obj):
# Agendas Diarias sempre serao ocultas da navegacao
exclude_from_nav = obj.exclude_from_nav
if hasattr(exclude_from_nav, '__call__'):
if safe_hasattr(exclude_from_nav, '__call__'):
exclude_from_nav = exclude_from_nav()
return exclude_from_nav

Expand Down
3 changes: 2 additions & 1 deletion src/brasil/gov/agenda/upgrades/v2000/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from brasil.gov.agenda.config import PROJECTNAME
from plone.app.textfield.value import RichTextValue
from plone.app.upgrade.utils import loadMigrationProfile
from Products.CMFPlone.utils import safe_hasattr
from zope.component.hooks import getSite

import logging
Expand All @@ -28,7 +29,7 @@ def fix_agendadiaria_update(context):
obj = brain.getObject()
update = u'' if not obj.update else obj.update

if hasattr(update, 'raw'):
if safe_hasattr(update, 'raw'):
continue
update = update.replace('\n', '<br />')
# Cria o valor RichText
Expand Down

0 comments on commit e3bd950

Please sign in to comment.