On Tuesday, September 16, 2014 12:21:07 AM UTC-7, eric cuver wrote:
>
> I'm on the home stretch of my application. I want to know I sought but I
> can not find. from the database. I have this problem.
>
> db.define_table ('spot'
> Field ('analyse_des_besoins', 'double') analyse_des_besoins== 50 %
> Field ('patent', 'double') 'patent===10%
> Field ('marketing', 'double') marketing === 20%
> Field ('design', 'double') design==10%
> Field ('definition_du_projet', 'double') == 20%
> Field ('time', 'time'))==1h20
>
> i must convert Field ('time', 'time')) in minute and then convert it in
> float to can calculate a percentage with each field ( Field
> ('analyse_des_besoins',Field ('patent',), Field ('marketing',
> 'double')...... )
>
> thank you
>
I think you're going to want to look at the Python time conversion and time
delta functions.
<https://docs.python.org/2/library/time.html>
Then I think you're to be looking at lambda functions or validators to set
the various fields.
It might help to focus the answers if you explain more about what you are
trying to do ... do any of these use-cases apply?
1) the user is providing the time field as an input, and the processing
uses pre-set percentages to compute the value in minutes of the other
fields.
2) the user is providing the time field as an input and also the
percentages for the other fields, and the processing computes the value in
minutes of the other fields.
3) the user is providing the other fields as values in minutes, and the
processing computes the total and percentages.
Also, are you using SQLFORM to handle the input, or some other method?
Which database engine are you using behind Web2Py? (That makes a
difference in some details of the answer, as there is some slight variation
in how time fields are handled by postgres, mysql, and sqlite. I would
guess that the databases found under Google Apps Engine and Amazon's cloud
might also have minor tweaks.
Good luck!
/dps
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.