[Grok-dev] Re: regebro-guido-templates: comments
    Jan-Wijbrand Kolman 
    janwijbrand at gmail.com
       
    Tue Oct 23 03:13:08 EDT 2007
    
    
  
Brandon Craig Rhodes wrote:
> Martijn Faassen <faassen at startifact.com> writes:
>  - I need to ask a question, which I'll do right here: In the web app
>    I have written, there were two or three pieces of information that
>    I turned out needing from many different views in my code.  I
>    discovered that if I declared a view:
> 
>     class Common(grok.View):
>         grok.context(Interface)
>         def update(self):
>            self.foo = 5
> 
>    then I could get the value of 'foo' from anywhere in any view by
>    calling something like:
> 
>     <b tal:content="context/@@common/foo">the Foo value</b>
> 
>    Is this a valid design pattern?  Or a broken way of getting
>    something that's much easier to achieve? :-)
I think this is a valid pattern. Well, at least, it is what I use :) For 
example to register a template that serves as the general layout macro 
(wow, did I dare mention *macros* in a alternative-templating-thread? ;).
regards,
jw
    
    
More information about the Grok-dev
mailing list