I think current generic.html is fine. It is better to keep it simple and
stupid.

On Tue, Nov 4, 2008 at 4:42 PM, mdipierro <[EMAIL PROTECTED]> wrote:

>
> Hi Iceberg,
>
> I am sorry I have to object to this proposal. For 3 reasons:
>
> 1) You can already edit your generic.html and make it behave the way
> you like
> 2) For new users it will make the process of rendering the views more
> obscure since it would behave in different ways depending on what they
> pass
> 3) It seems to encourage non writing views and putting more helpers in
> controllers when, instead, people should be writing views for thier
> actions.
>
> Massimo
>
> On Nov 4, 10:37 am, Iceberg <[EMAIL PROTECTED]> wrote:
> > I want to add one more comment about the benefit from my previous
> > suggestion.
> >
> > The worst thing about a dedicated foo.html approach, is that the
> > controller has to feed (sometimes fake) every variables which are
> > mentioned explicitly inside the foo.html, even when in error exit,
> > otherwise you are very likely to get a "global name xxxx is not
> > defined" error.
> >
> > With my suggested generic.html which eliminates the need for a
> > dedicated, decoration foo.html , now I can freely write this kind of
> > code in my controller, without caring foo.html anymore:
> >
> > def foo():
> >   # do something
> >   if all_is_ok:
> >     # instead of return dict(msg="ok", partA=dataA, partB=dataB), now
> > I do:
> >     return dict(DIV(partA,partB))
> >   else:
> >     # instead of return dict(msg="oops", partA=dummyA, partB=dummyB),
> > now I do:
> >     return dict(whatever="oops")
> >
> > On Nov4, 21:57, Iceberg <[EMAIL PROTECTED]> wrote:
> >
> > > Hi Massimo and all pals,
> >
> > > This post is about a tiny trick. Hopefully you will like it and
> > > include it in the next version of web2py.
> >
> > > I used to do this in controller:
> >
> > > def foo():
> > >   # do something
> > >   return dict(partA=some_words_in_a_table, partB=major_part_as_a_form)
> >
> > > so I need to write a foolish foo.html just to show contents BUT bypass
> > > the display of "partA" and "partB" themselves:
> > >   {{extend 'layout.html'}}
> > >   {{= partA}}
> > >   {{= partB}}
> >
> > > This is boring.
> >
> > > Finally, I got an idea and change the generic.html in this way:
> >
> > >   {{extend 'layout.html'}}
> > >   {{ # Bypass the _vars key name when there is only one object to be
> > > rendered. }}
> > >   {{content = response._vars.values()[0] if len(response._vars)==1
> > > else response._vars}}
> > >   {{=BEAUTIFY(content)}}
> >
> > > So, in above example, I can write the controller like:
> >
> > > def bar():
> > >   # do something
> > >   return dict( this_key_name_is_invisible = DIV(
> > >      some_words_in_a_table, major_part_as_a_form ) )
> >
> > > And I don't need the foolish foo.html anymore!
> >
> > > Hope the above explanation is clear and helpful to some of you. Thanks.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to