views don't register properly?

61 views
Skip to first unread message

Christoph

unread,
Jun 19, 2012, 5:57:39 AM6/19/12
to dexterity-...@googlegroups.com

Hello,

I'm in the process of switching to dexterity content types.Versions: Plone 4.1.4, Dexterity 1.2, I'm using the good-py set of versions.

The problem is that my views obviously don't get registered in the template registry, although I did (as far as I can tell) everything required - define the view, register it with grok, and reference the view in the GS XML file of my content type, just like it's described in the book and online tutorials. 


Thanks for shedding light on this!
best regards,
Christoph


Lukas Graf

unread,
Jun 19, 2012, 6:19:10 AM6/19/12
to dexterity-...@googlegroups.com
On Jun 19, 2012, at 11:57 AM, Christoph wrote:

I'm in the process of switching to dexterity content types.Versions: Plone 4.1.4, Dexterity 1.2, I'm using the good-py set of versions.

The problem is that my views obviously don't get registered in the template registry, although I did (as far as I can tell) everything required - define the view, register it with grok, and reference the view in the GS XML file of my content type, just like it's described in the book and online tutorials. 



The key here is
View <class 'eo.mm.massnahmed.View'> has no associated template or 'render' method
This means exactly what it says: Your view eo.mm.massnahmed.View needs to either have a render() method (for example if your view is returning plain text or JSON), or an associated template. By default, grok looks for templates for a module foobar.py in the directory foobar_templates, and the template files need to be named with the same name as the view class (lowercased).

The default template directory can be overriden with grok.templatedir(), and the template name with grok.template()


Lukas


------------------------------------------------------------
4teamwork - Internetbasierte Zusammenarbeit www.4teamwork.ch
Lukas Graf                           lukas...@4teamwork.ch
                                      Fon: +41 31 305 90 24
Engehaldenstrasse 53                Direkt: +41 31 511 04 22
3012 Bern, Switzerland                 Fax: +41 31 305 90 25
------------------------------------------------------------
Lesen Sie das Neuste über uns auf  www.twitter.com/4teamwork

Christoph

unread,
Jun 19, 2012, 6:33:14 AM6/19/12
to dexterity-...@googlegroups.com
Thanks, Lukas, this is exactly the structure I have in place. 
I have a module massnahmed, the directory is massnahmed_templates, and there's a view.pt file in there.

In the checkTemplates method in grokcore.view.templatereg, the following line returns None:

        # Lookup a template in the registry
        template = self.get(template_name)

Which means that somehow the template is not registered with the template registry, as I understand it.

best regards,
Christoph

David Glick

unread,
Jun 19, 2012, 1:06:06 PM6/19/12
to dexterity-...@googlegroups.com
What is the code of your view?
David

--
You received this message because you are subscribed to the Google Groups "Dexterity development" group.
To view this discussion on the web visit https://groups.google.com/d/msg/dexterity-development/-/zsDUHJ6Gs4AJ.
To post to this group, send email to dexterity-...@googlegroups.com.
To unsubscribe from this group, send email to dexterity-develo...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dexterity-development?hl=en.

Roché Compaan

unread,
Jun 19, 2012, 2:21:19 PM6/19/12
to dexterity-...@googlegroups.com
I'll try and be helpful here but unfortunately it will be in a very vague way.

I once came across the exact same issue. Everything in my code was
perfect but the template wasn't registered. I put pdb's inside the
template registration code and all templates got registered except for
the ones in my package.

I faintly recall that the order of eggs in my buildout.cfg was causing
this weird behaviour but unfortunately I can't recall the exact
problem. As unlikely as it may sound to be the solution, try and put
the Plone egg above plone.app.dexterity and put your own package below
these two packages in the list.

And put a pdb inside the register method of
grokcore/view/templatereg.py to see if your template is ever
registered.

--
Roché Compaan
Upfront Systems http://www.upfrontsystems.co.za

Christoph

unread,
Jun 20, 2012, 4:34:18 AM6/20/12
to dexterity-...@googlegroups.com
It's what we call 'lehrbuchmäßig' in Germany, just like it's said in every tutorial:

class View(grok.View):
    grok.context(IMassnahmed)
    grok.require('zope2.View')
    grok.name('view')

Christoph

unread,
Jun 20, 2012, 4:36:53 AM6/20/12
to dexterity-...@googlegroups.com
Thanks, Roché, this is helpful indeed. I'll test it in the way you propose. 

best regards,
Christoph

Christoph

unread,
Jun 22, 2012, 10:08:04 AM6/22/12
to dexterity-...@googlegroups.com
Actually, the template is never registered.
The following lines in grokcore.view.templatereg (in the findFileSystem method of the TemplateRegistry class) return None, the extension being 'pt':

            template_factory = zope.component.queryUtility(
                grokcore.view.interfaces.ITemplateFileFactory,
                name=extension)

The code keeps *continue*ing through the list of template files and never reaches the last line in the block:
self.register(template_name, template)

Going to find out now why the queryUtility returns None. (Still appreciating any helpful input, however. :)

best regards,
Christoph
Reply all
Reply to author
Forward
0 new messages