Changeset 5447 for main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
- Timestamp:
- 16 Aug 2010, 12:32:26 (14 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/accesscodes
- Files:
-
- 2 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
Note: See TracChangeset for help on using the changeset viewer.