~brad-marshall/charms/trusty/openstack-dashboard/fix-hacluster-config

« back to all changes in this revision

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

  • Committer: Liam Young
  • Date: 2014-08-13 14:26:30 UTC
  • mfrom: (33.1.2 openstack-dashboard)
  • Revision ID: liam.young@canonical.com-20140813142630-pqd132m0weoq1zz4
[gnuoy, rs=jamespage] Sync charm-helpers from lp: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