[Grok-dev] namespace() and alternate template languages

Martijn Faassen faassen at startifact.com
Wed Apr 15 11:40:42 EDT 2009


[context: Martin Aspeli triggered a discussion in another thread saying 
he was confused about namespace() and default_namespace(). This lead to 
this discussion]

Jan-Wijbrand Kolman wrote:
 > Right on both accounts; the default_namespace is defined by the template
 > __implementation__. A specific view using this template implementation
 > can then amend this namespace just before it is pushed into the template.

It would be nice if it were really that way, but unfortunately 
grokcore.view doesn't quite reflect this simplicity:

View has both a default_namespace() and a namespace() method.

GrokTemplate defines a namespace() per template language (I think?), 
that defers back to view.default_namespace() by default. It also defines 
getNamespace() which mixes the template language's namespace with the 
view's namespace.

PageTemplate's 'render' also updates the namespace some more taking in 
template.pt_getContext(), whatever that is.

Viewlets in grokcore.viewlet also need to plug into the namespace 
mechanism to add 'viewlet' and 'viewletmanager', but not necessarily for

No wonder Martin's confused. It's ripe for refactoring to something more 
less hard to understand, probably along the lines of what JW's sketching 
out above. I'm sure there are reasons it grew in this way, but I don't 
think we hit on entirely the right way yet.

I'd be interesting if alternate template language implementors said 
something about this too from their perspective.



More information about the Grok-dev mailing list