- Timestamp:
- 16 Aug 2010, 12:32:26 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/__init__.py
r5068 r5447 1 1 # Make this a package. 2 from waeup.sirp.accesscodes.accesscodes import get_access_code 3 4 # Public API of this submodule 5 __all__ = [ 6 get_access_code 7 ] 8 -
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py
r5153 r5447 409 409 site, )) 410 410 return 411 412 def get_access_code(access_code): 413 """Get an access code instance. 414 415 An access code here is a string like ``PUDE-1-1234567890``. 416 417 Returns ``None`` if the given code cannot be found. 418 419 This is a convenicence function that is faster than looking up a 420 batch container for the approriate access code. 421 """ 422 site = grok.getSite() 423 if not isinstance(access_code, basestring): 424 return None 425 try: 426 batch_id, ac_id = access_code.rsplit('-', 1) 427 except: 428 return None 429 if batch_id not in site['accesscodes'].keys(): 430 return None 431 batch = site['accesscodes'][batch_id] 432 try: 433 code = batch.getAccessCode(access_code) 434 except KeyError: 435 return None 436 return code -
main/waeup.sirp/trunk/src/waeup/sirp/jambtables/authentication.py
r5446 r5447 38 38 IApplicantPrincipalInfo, IApplicantPrincipal, IApplicantSessionCredentials, 39 39 IJAMBApplicantSessionCredentials) 40 from waeup.sirp.jambtables.util import get_applicant_data, get_access_code 40 from waeup.sirp.jambtables.util import get_applicant_data 41 from waeup.sirp.accesscodes import get_access_code 41 42 42 43 class PortalUser(grok.Role): -
main/waeup.sirp/trunk/src/waeup/sirp/jambtables/util.py
r5445 r5447 45 45 # XXX: Maybe we have to mark reg_no as used here? 46 46 return (applicant_data, entries[0]) 47 48 def get_access_code(access_code):49 """Get an access code instance.50 51 Returns ``None`` if the given code cannot be found.52 53 XXX: This should be moved to `accesscodes` as public API part.54 """55 site = grok.getSite()56 if not isinstance(access_code, basestring):57 return None58 try:59 batch_id, ac_id = access_code.rsplit('-', 1)60 except:61 return None62 if batch_id not in site['accesscodes'].keys():63 return None64 batch = site['accesscodes'][batch_id]65 return batch.getAccessCode(access_code)
Note: See TracChangeset for help on using the changeset viewer.