[Grok-dev] Template directories

Kevin Teague kevin at bud.ca
Thu Jun 26 00:15:59 EDT 2008


On Jun 25, 2008, at 4:43 AM, Brandon Craig Rhodes wrote:

> Tim Terlegård <tim.terlegard at valentinewebsystems.se> writes:
>
>> I wonder what people think about the current directory layout for
>> templates.  What about adding a global template directory? ...
>

+0.1

A single templates directory for all templates sounds somewhat  
appealing. In TextMate I use Command-T to jump between files, which  
searches on filenames. If I have 'app.py' and 'stuff.py' each with and  
index.pt template, then I can't type "Command-T app_.pt" to see a list  
of all the templates associated with the app module. Whereas if you had:

app.py
stuff.py
templates/app_index.pt
templates/stuff_index.pt

Then using TextMate for Grok would be a little easier. But I dunno,  
the way it is now works for me as well.

I do struggle a bit with class names for Views. I my current app I have:

app.py
  : class Index(grok.View)
app_templtes/index.pt
stuff.py
  : class StuffIndex(grok.View)
stuff_templates/stuffindex.pt

I guess the 2nd usage is kind of poorer form since I am repeating  
things?

> I'm afraid I would dislike this, because it would mean there was more
> than one place, when reading someone else's code, to go looking for
> their template.  I was struck, when reading a blog entry the other  
> day,
> by the statement that when someone went and looked at someone else's
> Rails app, he knew immediately right where to look for everything -
> where views would be, where models would be, and so forth.

Not having hard, fast rules like Rails does as to where things go also  
means that you have to spend some brain cycles making these decisions  
yourself. But then I *really* like the ability to organize code by  
concern instead of by component type. It's really nice to have a  
stuff.py file with a Model and a couple of Views in it. I don't have  
to bounce between three or four files like one would have to do in  
Rails. Some earlier Zope pacakges were structured out along the lines  
of:

bookpackage/
   adapters.py
   views.py
   content.py
   utilities.py

Which really says very little when delving into a project and looking  
over the filenames. Instead if you group code by the domain it's  
concerned with you get:

bookpackage/
   book.py
   bookstore.py
   checkout.py
   payment.py

One possible solution to the "what Indexes do I have? what Traversers  
do I have?" type of question is to add some bling introspection  
capabilities that show you component registries grouped by component  
type :)

Maybe some of the "soft conventions" (the ones that don't result in  
configuration actions) can be documented on Grok Naming Conventions  
page in the OGD (Official Grok Docs):

http://grok.zope.org/doc/dev/naming_conventions.html






More information about the Grok-dev mailing list