[Grok-dev] Viewlets for Layout--Multiple Forms per Context

rmoskal at mostmedia.com rmoskal at mostmedia.com
Wed Aug 13 00:16:12 EDT 2008


Greetings:

I've been working on a pretty basic CRUD application using GROK and decided that Viewlets were the way to go for having a common layout and swapping in and out UI elements depending on the context.

So far so good, though the code used to wrap a built-in grok form in a viewlet is the first bit of ugly code I've been forced to write.  We'll just chalk that up to growing pains.

I'm at a loss at how to provide two different forms for a particular context/content object.  I'd like to have a viewlet register a grok.DisplayForm by default, but to show an edit form when the user asks for it.  I have no problem creating viewlets for both forms, and having one or the other or both  both display for one of my domain objects. This is what the hierachy of contexts in my app looks like.  A Title is one of my domain objects.

Ledger (Container)
|
Titles (Container)
|
Title

So I can edit or view my domain object using a url like:

http://localhost:8080/ledger/titles/One

but I want to be able to edit the item like this:

http://localhost:8080/ledger/titles/One/edit

This is easy using views (it's the default way to do this), but I can't figure out how to accomplish this using viewlets. Someone mentioned that you can add and remove viewlets on the fly, but I'm having difficulty in wrapping my head around how.

Any pointers would be greatly appreciated.



Thanks and regards,


   

_______________
Robert Moskal
Most Media
Brooklyn, USA
347-529-4744
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/grok-dev/attachments/20080813/ad401308/attachment.html 


More information about the Grok-dev mailing list