Merge lp:~sinzui/charmworld/charm-object-damn-it-3 into lp:~juju-jitsu/charmworld/trunk

Proposed by Curtis Hovey
Status: Merged
Approved by: Curtis Hovey
Approved revision: 296
Merged at revision: 296
Proposed branch: lp:~sinzui/charmworld/charm-object-damn-it-3
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 73 lines (+8/-11)
3 files modified
charmworld/templates/hook.pt (+2/-2)
charmworld/views/charms.py (+2/-3)
charmworld/views/tests/test_charms.py (+4/-6)
To merge this branch: bzr merge lp:~sinzui/charmworld/charm-object-damn-it-3
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+172916@code.launchpad.net

Commit message

Always pass charm objects to the hook template.

Description of the change

Always pass charm objects to the hook template.

RULES

    This branch, pre-implementation: no one
    * The hook.pt template is still using the charm dict, but the view
      is working with an object. I neglected to remove the shim after I
      converted all the view code to use the object.

QA

    Verify these pages load.
    * http://staging.jujucharms.com/charms/precise/apache2/hooks/install
    * http://staging.jujucharms.com/~charmers/precise/apache2/hooks/install

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

Looks good, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/templates/hook.pt'
2--- charmworld/templates/hook.pt 2013-06-19 20:45:35 +0000
3+++ charmworld/templates/hook.pt 2013-07-03 21:39:24 +0000
4@@ -14,8 +14,8 @@
5
6 <metal:block fill-slot="content">
7 <div class="well">
8- <b>Charm</b>: ${charm["store_url"]} &nbsp;
9- <b>Revision</b>: ${charm['revision']} &nbsp;
10+ <b>Charm</b>: ${charm.store_url} &nbsp;
11+ <b>Revision</b>: ${charm.revision} &nbsp;
12 <b>Hook</b>: ${hook}
13 </div>
14 <pre class="prettyprint linenums" tal:content="hook_raw">
15
16=== modified file 'charmworld/views/charms.py'
17--- charmworld/views/charms.py 2013-07-03 19:58:15 +0000
18+++ charmworld/views/charms.py 2013-07-03 21:39:24 +0000
19@@ -144,14 +144,13 @@
20
21
22 def _hook_view(request, charm, hook):
23- charm_data = charm._representation
24 fs = getfs(request.db)
25- fileid = CharmFileSet.gen_fileid(charm_data, 'hooks/' + hook)
26+ fileid = CharmFileSet.gen_fileid(charm._representation, 'hooks/' + hook)
27
28 data = {
29 "project": request.registry.settings.get('project_name', 'Not Set.'),
30 "hook_raw": "Hook not found!",
31- "charm": charm_data,
32+ "charm": charm,
33 "hook": hook,
34 "onload": "prettyPrint()"
35 }
36
37=== modified file 'charmworld/views/tests/test_charms.py'
38--- charmworld/views/tests/test_charms.py 2013-07-03 19:58:15 +0000
39+++ charmworld/views/tests/test_charms.py 2013-07-03 21:39:24 +0000
40@@ -318,7 +318,7 @@
41 return charm
42
43 def test_hook(self):
44- charm = self.make_charm_with_files(promulgated=True)
45+ charm = Charm(self.make_charm_with_files(promulgated=True))
46 request = self.getRequest()
47 request.matchdict = {
48 'charm': 'sample_charm',
49@@ -330,12 +330,11 @@
50 self.assertEqual('install', response['hook'])
51 self.assertTrue(response['hook_raw'].startswith(
52 '#!/bin/bash\nset -eux\n\n# This PPA is no longer required.'))
53- charm_data = dict(Charm(charm)._representation)
54- self.assertEqual(charm_data, response['charm'])
55+ self.assertEqual(charm, response['charm'])
56 self.assertEqual('prettyPrint()', response['onload'])
57
58 def test_personal_hook(self):
59- charm = self.make_charm_with_files(promulgated=False)
60+ charm = Charm(self.make_charm_with_files(promulgated=False))
61 request = self.getRequest()
62 request.matchdict = {
63 'charm': 'sample_charm',
64@@ -348,8 +347,7 @@
65 self.assertEqual('install', response['hook'])
66 self.assertTrue(response['hook_raw'].startswith(
67 '#!/bin/bash\nset -eux\n\n# This PPA is no longer required.'))
68- charm_data = dict(Charm(charm)._representation)
69- self.assertEqual(charm_data, response['charm'])
70+ self.assertEqual(charm, response['charm'])
71 self.assertEqual('prettyPrint()', response['onload'])
72
73 def test_distro_charm(self):

Subscribers

People subscribed via source and target branches