Not sure I understand -- why do you need the "else" condition at all -- it 
doesn't do anything? Can't you just remove it?

On Wednesday, February 1, 2012 11:14:36 AM UTC-5, monotasker wrote:
>
> I include a comments plugin in my main view:
>
> {{=plugin_comments()}}
>
> That plugin calls this controller:
>
> #checks to see whether hidden 'honeypot' field has any text in it 
> (presumably placed there by a bot)
> def checkfilter(form):
>     form.vars.filter = request.vars.filter
>     if form.vars.filter == '':
>         pass
>     else:
>         form.errors.bot = 'It seems like you may not be a human being! \
>         If you are, be sure not to enter anything into any fields in the \
>         form other than the large box for the text of your comment.'
>
> def post():
>     comment = db.plugin_comments_comment
>     form = SQLFORM(comment, submit_button = 'add comment', separator = '', 
> formstyle = 'ul', hidden = dict(filter = ''))
>     # process form
>     if form.process(onvalidation = checkfilter).accepted:
>         response.flash = 'Thanks for your thoughts!'
>     elif form.errors.bot:
>         response.flash = form.errors.bot
>     elif form.errors:
>         response.flash = 'Sorry, something went wrong when I tried to add 
> your comment.'
>     else:
>         pass
>
>     comments = db(comment).select()
>     return dict(form = form, comments = comments)
>
> Which in turn loads this view:
>
> {{for comment in comments:}}
> <div class="comment">
>     {{=SPAN(comment.posted_by.first_name + ' ' + 
> comment.posted_by.last_name, _class='comment_author')}} 
> {{=SPAN(comment.posted_on.strftime('%B %e, %Y'), _class='comment_date')}}
>     <span class="comment_body">{{=comment.body}}</span>
> </div>
> {{pass}}
> {{=form}}
>
> It all works fine, except that if I don't end the form.process().accepted 
> test with pass in the "else" condition, then the "else" condition fires as 
> soon as the component loads.
>

Reply via email to