Some more info, this is the module code:
Post = db.define_table('post',
                       Field('author', 'reference auth_user',
default=auth.user_id, writable=False, readable=False),
                       Field('message', 'text', requires=IS_NOT_EMPTY(),
                             notnull=False, ),
                       auth.signature
                       )

On Thu, Jul 19, 2018 at 5:30 AM Anthony <abasta...@gmail.com> wrote:

> On Wednesday, July 18, 2018 at 1:08:24 AM UTC-4, Maurice Waka wrote:
>>
>> I have two problems;
>>
>>    1. When I successfully submit a form and try to retrieve the text for
>>    processing in the controller, I tend to get the previously submitted text
>>    and not the latest.
>>
>> What do you mean by this? What is the exact workflow, and what does your
> code look like? When a form is submitted, the controller action that
> handles the submission has access to the current submission (not the
> previous one).
>
>
>> def retrieve():
>>     dt=request.now
>>     row = db(db.post.author== auth.user.id).select(db.post.ALL, orderby=~
>> db.post.created_on == dt, limitby=(0,1)).first()
>>
>
> The above is not a valid "orderby" -- it must just be a field, not a
> query. There is no need for matching anything on request.now, and any
> inserts made during the current request would not match request.now
> exactly, as request.now is calculated before any of your app code runs (and
> therefore before any inserts can happen). Just order by created_on
> (descending) and take the first record. Anyway, this may not be what you
> really want -- if you're trying to get a given record right after it was
> inserted, this approach could lead to a race condition, as another record
> could be inserted before you do the read.
>
> 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/nvgzq49Z9kA/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