config('key') returns a difficult object

Bug #1182959 reported by Stuart Bishop
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Charm Helpers
Fix Released
Wishlist
Unassigned

Bug Description

The Serializable class returned by config() needs work. In particular, it doesn't implement __str__ allowing it to be used in string contexts like 'subprocess.check_call(['cmd', config('foo')])' or __nonzero__ allowing it to be used in boolean contexts like 'if config('foo'):'

Related branches

Matthew Wedgwood (mew)
Changed in charm-helpers:
status: New → Confirmed
importance: Undecided → Low
importance: Low → Wishlist
Revision history for this message
Stuart Bishop (stub) wrote :

Real problem here is that Serializable can only wrap dictionaries, and was being used to wrap string results (the juju helpers return single strings if there is a scope, or a dictionary of the whole dataset).

Revision history for this message
Stuart Bishop (stub) wrote :

Well, it *can* wrap other objects, but they are then broken. eg. Serializable('a')[0] explodes

Matthew Wedgwood (mew)
Changed in charm-helpers:
status: Confirmed → Fix Committed
Stuart Bishop (stub)
Changed in charm-helpers:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.