[Tutor] PHP

wesley chun wescpy at gmail.com
Sat Dec 4 23:02:46 CET 2010


On Sat, Dec 4, 2010 at 12:44 PM, Brett Ritter <swiftone at swiftone.org> wrote:
> On Sat, Dec 4, 2010 at 2:27 PM, Kirk Bailey <kbailey at howlermonkey.net> wrote:
>> and continue in html. What a BLOODY shame we can't do that in python,
>> which is otherwise awesome and superior in every way i can thus far
>> evaluate.
>
> As someone mentioned, you CAN do that in Python.  However, you'll find
> that mixing content and processing logic isn't considered a best
> practice.  Embedding simple display logic into your presentational
> templates is fine (looping, if conditional then display this section,
> etc), but you'll want to avoid mixing complicated logic in with
> presentation - it makes maintenance/testing/reuse that much harder,
> even moreso when working on a team with different skill specialties.


+1 on that point, which i failed to mention. :P

separating the logic from the template adheres more the common best
practice of using the MVC pattern. the template represents the "view,"
or the HTML template -- usually you want to keep this out of the hands
of developers and give it to your designers (UX/UE/UI) folks. on the
flip side, you want the controller (logic) to be the responsibility of
the programmers. this segregation of duties enables for more agile
development and creation of more accurate (and less confusing)
unit-testing and faster and cleaner development overall.

outside of the loops and conditionals mentioned, any real chunk of
code embedded in a template i'd consider a special case or deployment
issue (fewer approvals needed to push non-code, no need for server
restart on static file pushes, etc.).

cheers,
-- wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Python Web Development with Django", Addison Wesley, (c) 2009
    http://withdjango.com

wesley.j.chun :: wescpy-at-gmail.com
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com


More information about the Tutor mailing list