I moved the iteration to the controller side and it worked.
Regards

On Sat, Apr 7, 2018 at 5:36 PM, Anthony <abasta...@gmail.com> wrote:

> Also, there is not point to either of the for loops at the top of the view
> -- each loop is simply assigning a new value to the same variable, so the
> final value of the variable is just that of the final element in the
> iteration. You might as well just make that final assignment without
> bothering with iteration over all the previous items.
>
> Anthony
>
>
> On Saturday, April 7, 2018 at 10:34:28 AM UTC-4, Anthony wrote:
>>
>> {{for q in question:}}
>>> {{q=XML(q.quest.replace('\n','<br>').replace('(','{').replace(')','}'),
>>> sanitize=True)}}
>>> {{pass}}
>>> ...
>>>         $(function () {
>>>            ...
>>>
>>             sendMessage('{{=q}}');
>>>
>>
>> When "question" is empty (i.e., there are no answers from the current
>> user), the variable "q" will not be defined in the for loop, and therefore
>> will result in an exception later where you have {{=q}}.
>>
>> This doesn't have anything to do with @auth.has_membership('managers'),
>> as the error is not even occurring in the function with that decorator. If
>> you are expecting "question" to always include some records, you have to
>> figure out why you aren't getting any in this case. Otherwise, adjust your
>> code to account for the possibility of an empty "question".
>>
>> Anthony
>>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/YQhEantsews/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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

Reply via email to