[Grok-dev] Viewlets for Layout--Ok I get it
rmoskal
rmoskal at mostmedia.com
Wed Aug 13 23:48:17 EDT 2008
I took a closer look at the Grokstar appplication and now see how to
accomplish what I need to do.
The trick (or one trick) is that you need to declare a few top level views
that use the layout template file. So in the application module you have:
class Edit(grok.View):
grok.context(Interface)
grok.template('layout')
class Index(grok.View):
grok.context(Interface)
grok.template('layout')
class Add(grok.View):
grok.context(Interface)
grok.template('layout')
Then in the viewlet that wraps the appropriate form for the domain object
you reference the appropriate global view:
class TitleEdit(grok.Viewlet):
grok.context(Title)
grok.viewletmanager(Main)
grok.view(Edit)
def update(self):
self.form = getMultiAdapter((self.context, self.request),
name='editform')
self.form.update_form()
def render(self):
return self.form.render()
I was finally able to understand this by looking at Grokstar. My little
soliloquy helped me. I hope this tidbit helps someone else. I hope I
haven't annoyed the folks on the mailing list.
Regards,
Robert
--
View this message in context: http://www.nabble.com/Viewlets-for-Layout--Multiple-Forms-per-Context-tp18956744p18975304.html
Sent from the Grok mailing list archive at Nabble.com.
More information about the Grok-dev
mailing list