collective / collective.pwexpiry

Emulate Active Directory password complexity requirements.
1 stars 6 forks source link

get_default_language error in utils.py in send_notification_email (using notify_and_expire.py script) #18

Open petersta opened 8 years ago

petersta commented 8 years ago

I solved this as follows in function send_notification_email:

# add imports
from Products.CMFCore.utils import getToolByName
from zope.component.hooks import get Site

# and change in function send_notification_email:

try: 
    language = api.portal.get_default_language()
except:
    site = getSite()
    lt = getToolByName(site, 'portal_languages')
    language = lt.getDefaultLanguage()

`

frisi commented 8 years ago

iirc we're using the notify_and_expire.py script too and did not experience any errors. (@pcdummy?)

under which circumstances does your error happen? which plone version are you using?

a bare try except is generally not a good thing to have. try to catch a specific error.

if plone.api does not do a good job in finding the current default language it should probably fixed in there? https://github.com/plone/plone.api/blob/1.5/src/plone/api/portal.py#L366