Author rhettinger
Recipients alex, daniel.urban, pitrou, r.david.murray, rhettinger
Date 2011-02-23.19:41:04
SpamBayes Score 0.000622444
Marked as misclassified No
Message-id <>
FWIW, the new_child() and parents() part of the API was modeled after contexts in ANLTR where they are needed to overcome the limitations of Django's push/pop style which precludes a context from having multiple, independent children at the same time.  The module docstring in the recipe shows how new_child() can be used to easily model both dynamic scoping and nested scoping.

The other advantage of the new_child/parents API over the push/pop API is that it overcomes the occasional templating need to keep two copies of the context (before a push and after a push).

In some ways, it is more difficult to keep track of a mutating chain that is being continuously pushed and popped.  It is simpler to assign a chain to a variable and always know that it is associated with a given template and not have to worry about whether some utility function pushed a new context and failed to pop it when it was done.  A push/pop style introduces the same problems as matching matching malloc() with free() in C.
Date User Action Args
2011-02-23 19:41:06rhettingersetrecipients: + rhettinger, pitrou, alex, r.david.murray, daniel.urban
2011-02-23 19:41:06rhettingersetmessageid: <>
2011-02-23 19:41:04rhettingerlinkissue11297 messages
2011-02-23 19:41:04rhettingercreate