[Grok-dev] Viewlets

Daniel Lyons fusion at storytotell.org
Wed Jul 14 10:32:57 EDT 2010


Hi again,

I'm still working through _Grok 1.0 Web Development_ but also trying
to apply the lessons in a small app that does the same thing as the
todo list app, but structured somewhat differently. In the book,
pretty much everything winds up in the app.py file, which seems fine
for a tutorial, but as I rewrite it I have been trying to break things
down into app.py, todolist.py and todo.py but I've run into a
connundrum with handling viewlets. So I now think I may have
completely lost how viewlets work in my mind.

In general, how does one use viewlets to structure an application? I
have the master template in app_templates/master.pt but it seems as
though to use this template the view must be in app.py rather than
(say) todolist.py. Also, I'm wondering why it's strictly necessary to
have both a view and viewlet class. Seems like it's going to lead to
twice as many classes, one for each "page" I want to have and one to
embed that page in a viewlet. Is that right? Am I misunderstanding
something?

I did download and go through the Paleosoft sample code, but none of
those projects are using viewlets, so it was of somewhat limited
utility. Is there a medium-sized Grok project I can refer to that does
things right and uses viewlets?

Thanks again,

-- 
Daniel


More information about the Grok-dev mailing list