|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Problem with packages containing viewsHi all. I am just at the beginning, so my experience with grok is limited.
I managed to successfully have a views.py file containing grok.View classes, as well as a views_templates directory. Everything works smoothly and perfectly. Unfortunately, the views.py module is growing too much. As a result, I decided to convert the module into a package, and divide the file Views. I did - created views directory - copied views.py into views/__init__.py - removed views.pyc - moved views_templates into views/templates - added grok.templatedir("templates") into views/__init__.py (first lines, right after import grok) however, grok fails to find the templates for my views. What am I doing wrong? Thank you for your help Stefano _______________________________________________ Grok-dev mailing list Grok-dev@... https://mail.zope.org/mailman/listinfo/grok-dev |
|
|
Re: Problem with packages containing viewsHi Stefano,
I will first ask for some simple clarifications to find any real obvious mistakes - the kind I always seem to make :-) 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@...> 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? > - 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") > - 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") > > however, grok fails to find the templates for my views. > What am I doing > wrong? > > Thank you for your help > > Stefano > _______________________________________________ > Grok-dev mailing list > Grok-dev@... > https://mail.zope.org/mailman/listinfo/grok-dev > _______________________________________________ Grok-dev mailing list Grok-dev@... https://mail.zope.org/mailman/listinfo/grok-dev |
|
|
Re: Problem with packages containing viewsSteve 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@...> 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. _______________________________________________ Grok-dev mailing list Grok-dev@... https://mail.zope.org/mailman/listinfo/grok-dev |
|
|
Re: Problem with packages containing viewsStefano Borini wrote:
[snip] > 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 ? I suspect that it is looking for the templates directory *outside* of the package, similar to the way it worked for the module. After all, to Python your package's __init__.py is equivalent to a module of the same name. It's at least something we need to discuss, and any outcome needs to be documented carefully. Could you report this as an issue in launchpad? We are (slowly) working on revising the way grokcore.view works and this should be taken into account. Regards, Martijn _______________________________________________ Grok-dev mailing list Grok-dev@... https://mail.zope.org/mailman/listinfo/grok-dev |
| Free embeddable forum powered by Nabble | Forum Help |