I've checked better the situation.

After register computed fields are ok.

For example in the image_user16x16 field I have:
auth_user.image_user.928995a79b13d5d0.506f7274726169744356323031332d512e6a7067_image_user16x16.jpg

Link is ok in the view:
/download/default/auth_user.image_user.928995a79b13d5d0.506f7274726169744356323031332d512e6a7067_image_user16x16.jpg

But the image is not displayed.

If the user save again the profile, the image is displayed, also if the 
link is the same.

I've checked the upload folder. In fact after register the computed images 
are not created. When the user save again the profile computed images are 
created.

Someone have a solution?

Another way could be testing before displaying the image if the file exist.
I've tried like that but it returns always False:
os.path.isfile(URL('download', 'default', args=auth.user.image_user16x16))

Someone knows how I can do that?

Thanks.

Il giorno venerdì 17 febbraio 2017 11:34:14 UTC+1, Gael Princivalle ha 
scritto:
>
> 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