- Timestamp:
- 15 Jun 2011, 23:45:04 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py
r6359 r6374 6 6 from BTrees.OIBTree import OIBTree 7 7 from datetime import datetime 8 from hurry.workflow.interfaces import IWorkflowInfo 8 from hurry.workflow.interfaces import IWorkflowInfo, InvalidTransitionError 9 9 from random import SystemRandom as random 10 10 from waeup.sirp.interfaces import IWAeUPSIRPPluggable … … 12 12 IAccessCode, IAccessCodeBatch, IAccessCodeBatchContainer 13 13 ) 14 from waeup.sirp.accesscodes.workflow import DISABLED 14 from waeup.sirp.accesscodes.workflow import DISABLED, INITIALIZED 15 15 16 16 class ManageACBatches(grok.Permission): … … 448 448 return code 449 449 450 def _fire_transition(info, arg, toward=False): 451 try: 452 if toward: 453 info.fireTransitionToward(arg) 454 else: 455 info.fireTransition(arg) 456 except InvalidTransitionError: 457 return False 458 return True 459 450 460 def invalidate_accesscode(access_code): 461 """Invalidate AccessCode denoted by string ``access_code``. 462 463 The access code that belongs to the passed string must exist. 464 465 Fires an appropriate transition to perform the task. 466 467 Returns ``True`` if the ac was invalidated, ``False`` else. 468 """ 451 469 ac = get_access_code(access_code) 452 470 info = IWorkflowInfo(ac) 453 info.fireTransition('use') 454 return 471 return _fire_transition(info, 'use') 455 472 456 473 def disable_accesscode(access_code): 474 """Disable AccessCode denoted by string ``access_code``. 475 476 The access code that belongs to the passed string must exist. 477 478 Fires an appropriate transition to perform the task. 479 480 Returns ``True`` if the ac was disabled, ``False`` else. 481 """ 457 482 ac = get_access_code(access_code) 458 483 info = IWorkflowInfo(ac) 459 info.fireTransitionToward(DISABLED) 460 return 484 return _fire_transition(info, DISABLED, toward=True) 461 485 462 486 def reenable_accesscode(access_code): 487 """Reenable AccessCode denoted by string ``access_code``. 488 489 The access code that belongs to the passed string must exist. 490 491 Fires an appropriate transition to perform the task. 492 493 Returns ``True`` if the ac was reenabled, ``False`` else. 494 """ 463 495 ac = get_access_code(access_code) 464 496 info = IWorkflowInfo(ac) 465 info.fireTransition('reenable') 466 return 497 return _fire_transition(info, 'reenable')
Note: See TracChangeset for help on using the changeset viewer.