Commit d14b42d1 authored by Vincent Pelletier's avatar Vincent Pelletier

Person_createUserPreference: React on exception.

Rather than testing before calling.
parent 86bcf70b
...@@ -7,13 +7,14 @@ portal = context.getPortalObject() ...@@ -7,13 +7,14 @@ portal = context.getPortalObject()
if not portal.Base_checkPermission('portal_preferences', 'Add portal content'): if not portal.Base_checkPermission('portal_preferences', 'Add portal content'):
return return
if not context.getReference(): try:
# noop in case if invoked on non loggable object preference = portal.portal_preferences.createPreferenceForUser(
context.getReference(),
enable=True,
)
except ValueError:
return return
preference = portal.portal_preferences.createPreferenceForUser(
context.getReference(), enable=True)
preference.setTitle(translateString('Preference for ${name}', preference.setTitle(translateString('Preference for ${name}',
mapping=dict(name=context.getTitle().decode('utf-8')))) mapping=dict(name=context.getTitle().decode('utf-8'))))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment