I'd suggest finding an alternative way of handling this, the below can
become a real pain to maintain, not to mention the complexity of the
algorithm being a O(n3) will be extremely inefficient and can
potentially be very slow, try to minimize the use of "inner loops"
unless there is no other possible way, maybe by crafting a better query
that pulls the data.
Also, you don't have to create a form in the controller, in fact I
personally would not recommend this at all, even though web2py allows
"form helpers", this means that the "developer" will be creating these
UI elements where it should be done by the UI designer (even if it is
the same person), this sounds silly but is the basis of the "MVC" design
pattern, if you are starting with either web2py, python or developing in
general, try to stick to best practices and you'll slowly start
understanding why this is so important, especially when dealing with
large projects.
Having said that, using the standard Model-View-Controller Pattern which
web2py so elegantly implements, you'd end up doing something like this:
index.html:
<form method="post">
[all your form elements, including the loops etc]
</form>
index.py:
Call the query to return the data to pass to the view, create a kick-ass
query(ies) and try to optimize it as much as you can.
db.py (your controller)
DB Definitions
It is extremely simplistic, but it should get you started, there are
many examples you can read in this list, hope you find one that suits
your needs.
Regards,
Julio
On 07/09/2014 02:26 PM, Maria Levchenko wrote:
This is my view:
{{for row in texts:}}
{{=row.sentences}}: {{=row.meaning}}<br>
{{for ff in row.forms:}}
{{if len(ff)>0:}}
{{c=ff.split()}}<br>
<select> {{for cc in c:}} <option value = "cc">{{=cc}}</option>
<br> {{pass}}</select><br>
{{pass}}
{{pass}}
{{pass}}
<input type="submit">
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.