One thing - if you alias the top context at the top level, You'll end
up with memory leak - there will be a circular reference. It can be
avoided, if the context variable would hold a weakref.ref to the top
context.
On Apr 12, 5:04 pm, "Max Derkachev" <[EMAIL PROTECTED]> wrote:
> Well, you can alias a top-level context in a context variable, and
> then set the variable in that aliased context.
>
> class AliasContextNode(template.Node):
> def __init__(self, varname):
> self.varname = varname
> def render(self, context):
> context[self.varname] = context.dicts[0]
> return ''
>
> @register.tag
> def alias_context(parser, token):
> params = token.split_contents()
> return AliasContextNode(params[1])
>
> And then do something like
>
> {% alias_context top_context %}
> {% add_data "one" top_context %}
>
> Regards,
> Max
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---