~corey.bryant/charms/trusty/ceph-radosgw/ch-sync

« back to all changes in this revision

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

  • Committer: Corey Bryant
  • Date: 2014-09-27 17:33:59 UTC
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: corey.bryant@canonical.com-20140927173359-keqao0wissn2g973
Sync charm-helpers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
486
486
            hooks.execute(sys.argv)
487
487
    """
488
488
 
489
 
    def __init__(self):
 
489
    def __init__(self, config_save=True):
490
490
        super(Hooks, self).__init__()
491
491
        self._hooks = {}
 
492
        self._config_save = config_save
492
493
 
493
494
    def register(self, name, function):
494
495
        """Register a hook"""
499
500
        hook_name = os.path.basename(args[0])
500
501
        if hook_name in self._hooks:
501
502
            self._hooks[hook_name]()
502
 
            cfg = config()
503
 
            if cfg.implicit_save:
504
 
                cfg.save()
 
503
            if self._config_save:
 
504
                cfg = config()
 
505
                if cfg.implicit_save:
 
506
                    cfg.save()
505
507
        else:
506
508
            raise UnregisteredHookError(hook_name)
507
509