Hi Speedbird,
actually I agree with you on almost everything.
But I am sure we can agree there are exceptions. There are times when
you need to generate HTML programmatically. Think of serializing in a
tree recursively. The web2py helper system provides a way to avoid
using raw html.
I also agree about minimizing the use of code in views but your
example may be misleading. The main purpose of {{def ...:}}...
{{return}} in views is not that of defining Python functions (although
you can) but HTML functions (pieces of HTML that you want to reuse).
That is the web2py equivalent of Django blocks. You do exactly for the
purpose of generating html in controllers.
Massimo
On Jan 4, 1:31 pm, Speedbird <[email protected]> wrote:
> First of all, thanks to Massimo and the community for providing an
> impressive framework to work with.
>
> Being a Zope developer (and back-end python programmer) for the past
> 10 years (and soon to web2py convert) , I'd like to share one of the
> issues that I have struggled since the early days of DTML.
>
> Please, please do not mix presentation and logic in the controller,
> things such a THEAD(TR(TD('<hello>')),_class='myclass',_id=0) from
> "controller.py" tends to be very attractive to the novice programmer,
> but other than for debugging or testing purposes, IMHO should be
> avoided, nailed its practice into an iron coffin and throw it in the
> deepest sea.
>
> On the other side of the spectrum, adding python logic into the view
> (again IMHO should also be avoided like the plague) Consider the
> following:
>
> From myview.html:
>
> {{def foobaz():}}
> <h1>This is the baz</h1>
> {{return}}
>
> Let me tell you why, at least in the "enterprise" realm this would
> become a big problem: You will eventually have to work with a team
> (yes, a team of programmers, business analysts, database designers and
> user interface monkeys), you want to give the UI guys the "cleanest"
> html code for the to play with and mock-up, you know, to keep the
> "biz" side happy, etc, what's the point in giving the UI guy (which
> may not know python at all) a hello.html with only a {{=respone.glob}}
> statement on it?, or on the other hand, you have the purist "python
> guy" in the IT dungeon lair and all of the sudden you provide him with
> pseudo-html embedded in functions in which he was expecting take care
> of logic issues in the code.. see my point?
>
> Please do not get me wrong, I honestly like web2py *a lot*, I just
> don't want to see it becoming a nuisance programming-wise instead of a
> solid framework tool to introduce in my company. Thanks you all and
> keep up the excellent work.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---