OK, I know I can't get a sum of virtual fields, but here's what I'm trying 
to do:

db.define_table(
    't_periods',
    Field('f_start', type='datetime', label=T('Start time')),
    Field('f_end', type='datetime', label=T('End time')),
    Field('f_task', type='reference t_tasks', label=T('Task')),

    ...)

db.t_periods.f_duration = Field.Virtual('f_duration',
                                        lambda row: row.f_end - row.f_start)



So, for any one task there may be multiple periods of time. I would like a 
list of tasks and the total time allocated to each. I tried this:

task_duration = db.t_periods.f_duration.sum()

results = db(query).select(db.t_tasks.f_name, task_duration, 
                           groupby=db.t_tasks.f_name)

That gives me the error:

AttributeError: 'FieldVirtual' object has no attribute 'sum'

That makes sense to me, but what would be a good strategy to get a list of 
tasks and the total duration for each?

Thanks

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