Quantcast

traversal error when calling template for grok.View

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

traversal error when calling template for grok.View

David Bain-5
I have a simple class in app.py

class Master(grok.View):
    """The master page template macro."""
    # register this view for all objects
    grok.context(Interface)


there is a master template in app_templates/master.pt

The following code gives a traversal error:

hey = Master
hey(None,None)._render_template()
*** TraversalError: (None, 'master.css')

_______________________________________________
Grok-dev mailing list
[hidden email]
http://mail.zope.org/mailman/listinfo/grok-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: traversal error when calling template for grok.View

Brandon Craig Rhodes
"David Bain" <[hidden email]> writes:

> hey(None,None)._render_template()

This line of code, by the way, seems to answer your question from
earlier today - the way you get a template to render something for you
is to instantiate its View, just like (I think) you're doing here.

> The following code gives a traversal error:
>
> hey = Master
> hey(None,None)._render_template()
> *** TraversalError: (None, 'master.css')

Does your template try to determine the URL to "master.css" anywhere?
Whenever, in a template, you say "get the URL of <this>", you have to
make sure that "<this>" can be "traversed" to find where it lives and,
perhaps in this case, what lives inside of it.

Take a look at:

   http://grok.zope.org/minitutorials/transient-objects.html

and see whether it addresses your situation.

--
Brandon Craig Rhodes   [hidden email]   http://rhodesmill.org/brandon
_______________________________________________
Grok-dev mailing list
[hidden email]
http://mail.zope.org/mailman/listinfo/grok-dev
Loading...