Controllers do not see code in other controllers, for logical reasons,
since they act on different requests.
Controllers only see code in models. You need to put the code in a
model file or in a module. If you put in a module you need to modify
it so that request, response are passe to the decorator.

About being pythonic.... I agree and disagree:

You say

> {{text|e}} <= pretty
>
> {{escape(text)}} <= not so much

Fine but none of those examples is web2py-ese. This is the equivalent
code in web2py:

{{=text}}

In web2py text is escaped by default. It is a MUST of security.

You also say

> pretty
> {% for stuff in other_stuff %}
> do stuff with {{stuff}}
> {% endfor %}
>
> not so much
> {{ for stuff in other_stuff }}
> do stuff with {{=stuff}}
> {{pass}}

Again, none of those is valid web2py-ese. In web2py you do

{{ for stuff in other_stuff: }}
do stuff with {{=stuff}}
{{pass}}

 I find the second better because it uses python keywords instead of
made up keywords (endfor?).

The main problem I have with Django and Jinja is logical. Here is an
example

IN DJANGO:

layout.html:
<html><body><h1>{% block test %}nothing{% endblock %}</h1></body></
html>

index.html:
{% extends 'layout.html %} hello {% block test %}world{% endblock %}

renders as "<html><body><h1>world</h1></body></html>"

Where does hello go? Logically this is a problem.

IN WEB2PY
layout.html:
<html><body>{{include}}<h1>{{test()}}</h1></body></html>

index.html:
{{extend 'layout.html'}} hello {{def test():}}world{{return}}

renders as "<html><body> hello <h1>world</h1></body></html>".

The extending layout is {{include}}d in a specific point so any
leftover text is inserted there. No text gets lost.
Moreover in web2py blocks are functions (this is more pythonic) and I
can even pass variables to them.

Massimo



--~--~---------~--~----~------------~-------~--~----~
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