[Grok-dev] Problem with packages containing views
Stefano Borini
stefano.borini at ferrara.linux.it
Thu Oct 8 07:38:30 EDT 2009
Steve Schmechel wrote:
> Hi Stefano,
>
> I will first ask for some simple clarifications to find any real
> obvious mistakes - the kind I always seem to make :-)
I'm pretty sure it is, as the fact is rather strange.
> If this doesn't help and it turns out to be something deep in the
> grokking process, someone else will hopefully help as I am not a
> guru in that area.
>
> Comments are in-line:
>
> --- On Wed, 10/7/09, Stefano Borini <stefano.borini at ferrara.linux.it> wrote:
>> - created views directory
>> - copied views.py into views/__init__.py
> Do you mean that you copied all the code from the "too big" views.py
> module into __init__.py?
> You didn't further break the code into modules within the package?
No, just copied without further breaking. I wanted to do this in steps.
The first obvious step was to make the package behave like the module.
>> - removed views.pyc
>> - moved views_templates into views/templates
> Do you mean you moved the contents of the directory (views_templates/*.pt)
> into the views/templates directory?
> (For example - "views/templates/myview.pt"
> **not** - "views/templates/views_templates/myview.pt")
exactly. The layout is now
views/__init__.py
views/templates/foo.pt
views/templates/bar.pt
views/templates/baz.pt
>> - added grok.templatedir("templates") into
>> views/__init__.py (first
>> lines, right after import grok)
> Question to grok devs: Is the __init__.py of a package grokked also or just the appropriate classes defined within other modules in a package?
> (Maybe it doesn't matter, but it would be an odd place to try to follow
> the default template directory naming convention, as you would
> potentially get a template for a view defined in __init__.py expected
> at: "__init___templates/someview.pt")
This prompts me to put it into a different module and see.
aaaand... it works.
This layout works.
views/__init__.py
views/templates/foo.pt
views/templates/bar.pt
views/templates/baz.pt
views/test.py
I moved __init__.py into test.py, and left __init__.py empty (it should
not matter to import test. test.py will be grokked anyway)
Ok, so the fact appears to be that anything in __init__.py is apparently
grokked (otherwise I would not get the message about the missing
template for a View class, the class would simply be skipped), but
something does not find the template dir, even if specified explicitly
with grok.templatedir().
Bug or feature ?
Thanks for the help! :)
By the way, I'm not running the 1.0. I'm running the latest beta.
More information about the Grok-dev
mailing list