Use getFromKeyFields instead of getForFields where possible
Lookup by key_name is a lot faster than doing a query, so if possible
the use of getFromKeyFields is preferred over getForFields.
Patch by: Sverre Rabbelier
--- a/app/soc/logic/cleaning.py Sat Mar 21 18:15:18 2009 +0000
+++ b/app/soc/logic/cleaning.py Sun Mar 22 14:51:37 2009 +0000
@@ -162,8 +162,7 @@
"""
link_id = clean_link_id(field_name)(self)
- user_entity = user_logic.getForFields({'link_id': link_id},
- unique=True)
+ user_entity = user_logic.getFromKeyFields({'link_id': link_id})
if not user_entity:
# user does not exist
@@ -205,8 +204,7 @@
"""
link_id = clean_link_id(field_name)(self)
- user_entity = user_logic.getForFields({'link_id': link_id},
- unique=True)
+ user_entity = user_logic.getFromKeyFields({'link_id': link_id})
if user_entity:
# user exists already
@@ -430,8 +428,8 @@
# if both fields were valid do this check
if link_id and user_account:
# get the user from the link_id in the form
- fields = {'link_id': link_id}
- user_entity = user_logic.getForFields(fields, unique=True)
+
+ user_entity = user_logic.getFromKeyFields({'link_id': link_id})
# if it's not the user's current account
if user_entity.account != user_account: