~nuclearbob/charms/trusty/qlbr/dev

« back to all changes in this revision

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

  • Committer: Max Brustkern
  • Date: 2014-10-01 19:55:45 UTC
  • mfrom: (80.1.11 qlbr-payload)
  • Revision ID: max@canonical.com-20141001195545-2bkkqdhof8ipvdm5
Added payload support

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