[Grok-dev] Using autogenerated forms together with a master template

Kamon Ayeva kamon.ayeva at gmail.com
Tue Apr 1 09:41:07 EDT 2008


On Tue, Mar 18, 2008 at 10:32 PM, Fernando Correa Neto <fcdoth at gmail.com> wrote:
> Hey,
>
>
>  On Tue, Mar 18, 2008 at 5:08 PM, Andreas Jung <lists at zopyx.com> wrote:
>  > Hi,
>  >
>  >  I have an application using a master template with a "main" slot.
>  >  What is the solution for autogenerating the edit views within the main slot
>  >  of the master template?
>
>  I think the solution here is to provide a customized version of the
>  default edit template that uses that macro IIRC.

In my simple app package, in the app.py, I have something like

# A Master view which brings a master template
class Master(grok.View):
    """The master page template macro"""
    grok.context(zope.interface.Interface)

# A specific form template
form_template = grok.PageTemplateFile('form.pt')

And my edit view class starts with something like:

class Edit(grok.EditForm):
    grok.context(ISiteContent)
    grok.name('edit')
    grok.template('form_template')

    grok.require('grok.ManageSite')

To go with that I have a 'form.pt' (I had to put it directly at the
root of the package, not in a the app_templates folder), and of course
a 'master.pt' in the app_templates.

Hope that helps.
IIRC I found the information by reading the doctests in the Grok package.

-- Kamon


More information about the Grok-dev mailing list