~ivoks/charms/trusty/neutron-gateway/mtu-vlan

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/core/hookenv.py

  • Committer: Corey Bryant
  • Date: 2014-07-09 19:25:29 UTC
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: corey.bryant@canonical.com-20140709192529-c2azv58whgj6dnmd
Sync with charm-helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
def cached(func):
26
26
    """Cache return values for multiple executions of func + args
27
27
 
28
 
    For example:
 
28
    For example::
29
29
 
30
30
        @cached
31
31
        def unit_get(attribute):
445
445
class Hooks(object):
446
446
    """A convenient handler for hook functions.
447
447
 
448
 
    Example:
 
448
    Example::
 
449
 
449
450
        hooks = Hooks()
450
451
 
451
452
        # register a hook, taking its name from the function name
452
453
        @hooks.hook()
453
454
        def install():
454
 
            ...
 
455
            pass  # your code here
455
456
 
456
457
        # register a hook, providing a custom hook name
457
458
        @hooks.hook("config-changed")
458
459
        def config_changed():
459
 
            ...
 
460
            pass  # your code here
460
461
 
461
462
        if __name__ == "__main__":
462
463
            # execute a hook based on the name the program is called by