heat/heat
Angus Salkeld 734f777da4 Use "if stack is not None" and not "if stack"
Problem:
If a nested stack has no resources, then we do not get
a "nested" link in the resource information returned by
our API.

Why?
In engine/api.py we have:

if (hasattr(resource, 'nested') and callable(resource.nested) and
            resource.nested()):
         res[rpc_api.RES_NESTED_STACK_ID] = dict(resource.nested().identifier())

The problem with this is the python definition of False, from the docs:

"instances of user-defined classes, if the class defines a __nonzero__()
 or __len__() method, when that method returns the integer zero or bool
 value False. [1]"

So if you have a stack with zero resources (len() returns 0), the
stack will be False :-O

Solution:
Use "if stack is not None:" instead of "if stack".

Change-Id: Ibdd1cb5dee6ce8e58f7d8f2586a495caded79134
Closes-bug: 1416917
2015-02-02 20:10:20 +10:00
..
api Merge "Expose stack_user_project_id in stack-show" 2015-01-29 04:44:40 +00:00
cloudinit Enable H305 and H307 style checks 2015-01-20 09:47:25 +02:00
cmd Remove deprecated function i18n.install('heat') 2014-10-13 10:31:28 +08:00
common Fix the standalone authentication mechanism 2015-01-30 16:53:33 +11:00
db Store auth_url and region_name when trusts are enabled 2015-01-29 13:17:55 +00:00
engine Use "if stack is not None" and not "if stack" 2015-02-02 20:10:20 +10:00
locale Imported Translations from Transifex 2015-01-29 06:18:05 +00:00
openstack Merge "Cleanup heat/openstack/common" 2015-01-08 12:40:14 +00:00
rpc Expose stack_user_project_id in stack-show 2015-01-22 12:29:06 +13:00
scaling Enable H305 and H307 style checks 2015-01-20 09:47:25 +02:00
tests Use "if stack is not None" and not "if stack" 2015-02-02 20:10:20 +10:00
__init__.py Remove deprecated function i18n.install('heat') 2014-10-13 10:31:28 +08:00
version.py Make the first line of every file consistent. 2014-03-04 09:03:04 -06:00