[Grok-dev] "Apply" a pagetemplate to an object and get html back

Achim Domma domma at procoders.net
Sat Jul 19 03:41:02 EDT 2008

Am 18.07.2008 um 22:41 schrieb Lennart Regebro:

> On Fri, Jul 18, 2008 at 21:16, Achim Domma <domma at procoders.net>  
> wrote:
>> grok, I'm developing some kind of yet-another-mini-cms. I want to  
>> let the
>> user edit the page body via a webform using textile or markdown  
>> for example.
>> Then I would provide tags to display some kind of specialized  
>> lists like
>> "events", "links", ...
>> How do I do that using grok? Or is there a better approach to  
>> solve my
>> problem?
> You create a View. This object will sit "inbetween" the object and  
> the template.
> so:
> class TheObject(grok.Model):
>   blablabal
> class TheView(grok.View):
>   blablabla
> theview = Template("<html>abasdjasbksdaksdjak</html>")
> This will give you a /template on all TheObject objects, that will
> render the template.

I don't understand your solution, but perhaps my question was not  
exact enougth. I have

class Page(grok.Model):

class Event(grok.Model):

class TheView(grok.View):
    def render_body(self):
        here I use textile/markdown to format the body of
        the page. and I also want to iterate over a list of
        events and want to create a html snippet for each on.

In the page template of TheView I will use the render_body method. So  
I could create a view for Event but then I still have to call them to  
produce some html for me.


More information about the Grok-dev mailing list