Thank you Leonel but I think it don't resolve the bug. Perhaps I've done 
something wrong.

I've already some actions to do for both events so I've some lambda 
functions (I've take off the other things from the functions):

auth.settings.profile_onaccept = lambda form: profile_onaccept(form)
auth.settings.register_onaccept = lambda form: register_onaccept(form)

## TODO: remove me when fixed, this is to avoid a bug with computed fields 
not being updated in session
def force_compute_fields(form):
    if auth.user:
        user = db.auth_user[form.vars.id]
        table_user = auth.table_user()
        computed_field_functions = {f:table_user[f].compute for f in 
table_user.fields if table_user[f].compute}
        user.update_record(**{f:y(user) for f,y in computed_field_functions.
iteritems()})
        auth.user.update({f:user[f] for f in computed_field_functions})  # 
Update session values as well
# end

def profile_onaccept(form):
    force_compute_fields

def register_onaccept(form):
    force_compute_fields


Website is :
https://www.mtbconnection.com .

That's a real problem if we can't compute fields on register.

Can I make a scheduler function that'll check every minute if a file is not 
compute and launch something that'll compute all fields from this user?

Il giorno giovedì 16 febbraio 2017 23:20:07 UTC+1, Leonel Câmara ha scritto:
>
> Yes. There are 2 web2py bugs here. The first one that is probably 
> affecting you is that auth.user which is cached in the session is not being 
> updated with the thumbnail values. The second one you can read about here:
> https://groups.google.com/forum/#!topic/web2py-developers/gwEr1cHQNAY
>
> Anyway, while these aren't fixed, here's a dirty workaround:
>
> ## TODO: remove me when fixed, this is to avoid a bug with computed fields 
> not being updated in session
> def force_compute_fields(form):
>     if auth.user:
>         user = db.auth_user[form.vars.id]
>         table_user = auth.table_user()
>         computed_field_functions = {f:table_user[f].compute for f in 
> table_user.fields if table_user[f].compute}
>         user.update_record(**{f:y(user) for f,y in 
> computed_field_functions.iteritems()})
>         auth.user.update({f:user[f] for f in computed_field_functions})  # 
> Update session values as well
>
>
> auth.settings.register_onaccept = auth.settings.profile_onaccept = [
> force_compute_fields]
> # end
>
>

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