Just stumbled across what might be a small bug when using namespaces.
It seems that if you define a namespace, but don't define any vars in
a call to render then you get a KeyError for the namespace. Looking at
the code it seems that the Namespace object is only created for T.vars
when vars exist although the _g variable always tries to reference
T.vars[ns] if namespace is defined.
A fix would be duplicating the namespace creation check in vars for
_gs.
E.g.
_g = { }
_g.update (T.tags)
if ns:
/* Get KeyError if the following two lines are omitted
and a namespace is specified whilst vars is None */
if not T.vars.has_key ( ns ):
T.vars [ ns ] = Namespace ( )
/* End */
_g [ ns ] = T.vars [ ns ]
else:
_g.update (T.vars)
Apologies in advance if this isn't a bug and I have just go it wrong
somewhere.
Martin
> A fix would be duplicating the namespace creation check in vars for
> _gs.
> E.g.
>
> _g = { }
> _g.update (T.tags)
> if ns:
> /* Get KeyError if the following two lines are omitted
> and a namespace is specified whilst vars is None */
> if not T.vars.has_key ( ns ):
> T.vars [ ns ] = Namespace ( )
> /* End */
> _g [ ns ] = T.vars [ ns ]
> else:
> _g.update (T.vars)
>
I'll take a look at this. It might just be viable to use {} rather than
None for the default value of vars.
Cliff