Changeset 6121 for main/waeup.sirp


Ignore:
Timestamp:
16 May 2011, 17:23:12 (13 years ago)
Author:
uli
Message:

Use catalogs when looking up applicants.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/root.py

    r6119 r6121  
    2424"""
    2525import grok
     26from hurry.query import Eq
     27from hurry.query.interfaces import IQuery
     28from zope.component import getUtility
    2629from waeup.sirp.interfaces import IWAeUPSIRPPluggable
    2730from waeup.sirp.accesscodes import get_access_code
     
    97100    ``APP`` or ``PUDE``, ``XXX`` the access code series and
    98101    ``YYYYYYYYYY`` the real accesscode number.
     102
     103    This function requires a fully blown setup as it does catalog
     104    lookups for finding applicants.
    99105    """
    100     site = grok.getSite()
    101     for container in site['applicants'].values():
    102         applicant_data = container.get(identifier, None)
    103         if applicant_data is not None:
    104             return applicant_data
    105     return None
     106    query = getUtility(IQuery)
     107    results = list(query.searchResults(
     108            Eq(('applicants_catalog', 'access_code'), identifier)
     109            ))
     110    if len(results) == 0:
     111        return None
     112    return results[0]
    106113
    107114def application_exists(identifier):
Note: See TracChangeset for help on using the changeset viewer.