Login Register

New Context Object Abilities

Unlike the page serving model of Django, we can keep our Context objects around between each template render. What we want to be able to do is quickly clone an existing context, and either reduce, or add to, the data in the object. To do this, there are two new functions:

  • filter: Just put the keys you want to key in its arguments to get only those keys back in a cloned Context.
  • extend: Just pass it an object to get a cloned Context containing all of the old keys, plus the new ones.

Some new functions are added to allow tags to communicate with the rendering object.

  • setThis: Sets the object on which to perform operations. Used by the attach attribute tag, for example.
  • getThis: Used by tags, gets the currently set this object.