Commit 10773ebe authored by Vincent Pelletier's avatar Vincent Pelletier

PreferenceTool: Get acl_users by acquisition.

acl_users is one of the rare objects (with SQL connectors) which are
intended to be fetched by acquisition, allowing overrides.
Also, move code out of try..finally block where possible.
parent 911c9f4d
......@@ -253,12 +253,12 @@ class PreferenceTool(BaseTool):
"""Creates a preference for a given user, and optionnally enable the
preference.
"""
user_folder = self.acl_users
user = user_folder.getUserById(username)
if user is None:
raise ValueError("User %r not found" % (username, ))
security_manager = getSecurityManager()
try:
user_folder = self.getPortalObject().acl_users
user = user_folder.getUserById(username)
if user is None:
raise ValueError("User %r not found" % (username, ))
newSecurityManager(None, user.__of__(user_folder))
preference = self.newContent(portal_type='Preference')
if enable:
......
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