What's the downside? I can see 3 downsides:    1. Generated code becomes more complicated  2. Generated code won't work with Python 3.5  3. We'll be changing the recommended way to write middleware in future, making this generated code deprecated.    I think (2) and (3) could be valid reasons not to have it as an example. Are they the case?   As for (1), I think it worths it to have a proper implementation there, even if it means slightly more generated code.