Magnus Heino wrote:
- inside the function, REQUEST is either a Request instance (boolean true) or 'None' (boolean false), so testing for 'if REQUEST is not None:' is equivalent to 'if REQUEST:'
Nope.
A Request instance is not the same thing as boolean True.
I meant it as: in a boolean context the value of the REQUEST object, which is a Request class instance, is 'true', in other words an 'if REQUEST' will always succeed.
So using a instance as boolean true depends on the implementation of the class... thats why you always need to test for None.
REQUEST is an instance of the class Request, which is an alias for HTTPRequest, which is derived from BaseRequest, which has a method __len__ that returns the constant 1, which is 'true', so REQUESTS are *always* 'true'. - Willem