Hi,
I thought the @@pas_search view was going to let me search for users by
a uniform search key that would check both title/fullname and id/login.
The interface declaration seems to promise this too, but the
implementation doesn't.
I know that the sharing view does this, but the sharing.py file now has
this block of Perl:
def user_search_results(self):
"""Return search results for a query to add new users.
Returns a list of dicts, as per role_settings().
"""
def search_for_principal(hunter, search_term):
def merge(results, key):
return dict([(result[key], result) for result in
results]).values()
return merge(chain(*[hunter.searchUsers(**{field: search_term})
for field in ['login', 'fullname']]
), 'userid')
def get_principal_by_id(user_id):
acl_users = getToolByName(aq_inner(self.context), 'acl_users')
return acl_users.getUserById(user_id)
def get_principal_title(user, default_title):
return user.getProperty('fullname') or user.getId() or
default_title
return self._principal_search_results(search_for_principal,
get_principal_by_id, get_principal_title, 'user', 'userid')
Whooo!
Is there a nice way to do this without resorting to this block of code
(there's more...)?
Thanks,
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers