Message129220
| 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 |
<1298490066.21.0.649999695257.issue11297@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 http://code.activestate.com/recipes/577434/ 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. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2011年02月23日 19:41:06 | rhettinger | set | recipients:
+ rhettinger, pitrou, alex, r.david.murray, daniel.urban |
| 2011年02月23日 19:41:06 | rhettinger | set | messageid: <1298490066.21.0.649999695257.issue11297@psf.upfronthosting.co.za> |
| 2011年02月23日 19:41:04 | rhettinger | link | issue11297 messages |
| 2011年02月23日 19:41:04 | rhettinger | create |
|