Merge lp:~stub/charm-helpers/hook-magic into lp:charm-helpers
Proposed by
Stuart Bishop
Status: | Merged |
---|---|
Merged at revision: | 40 |
Proposed branch: | lp:~stub/charm-helpers/hook-magic |
Merge into: | lp:charm-helpers |
Diff against target: |
35 lines (+18/-0) 2 files modified
charmhelpers/core/hookenv.py (+3/-0) tests/core/test_hookenv.py (+15/-0) |
To merge this branch: | bzr merge lp:~stub/charm-helpers/hook-magic |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Page | Approve | ||
Review via email: mp+172109@code.launchpad.net |
Description of the change
If an explicit hook name is not provided, register the function with both the function name and the function name with underscores replaced with hyphens. This allows the following to work as you would expect:
@hooks.hook()
def upgrade_charm():
pass
I can only see this magic causing hassles in pathalogical situations (eg. two relations with names only differing by hypen or underscore choice), but is easily worked around by using an explicit hook name.
To post a comment you must log in.
Hi Stuart
Looks good - aside from one minor lint issue:
tests/core/ test_hookenv. py:712: 9: E301 expected 1 blank line, found 0
However its more work for you to update that and resubmit than me just to fix it on merge.
+1