This might be a strange question to ask here, but I think it's DAL relevant.
I'm reading an attendance table which has to display a table by employee
and weekday, calculating subtotals and total. something like this mockup:
*EMPLOYEE # 1234*
---------------------------------------
Sun | Mon | Tue | Wed | Thu | Fri | Sat
---------------------------------------
| 3hr | 3hr | 3hr | 3hr | 3hr | 3hr
| 2hr | 2hr | 2hr | 2hr | 2hr |
| | | 1hr | | |
---------------------------------------
0hr | 5hr | 5hr | 6hr | 5hr | 5hr | 3hr
---------------------------------------
*29 Hours this week*
I'm not that fluent in Python, but it seems like doing this with plain
python would need a complicated loop.
I've worked with RPG (the language, not the game genre :) and it solves
this kind of loops elegantly, by reading ahead 1 record and signaling
matches with with booleans (called indicators).
- LR (Last Record indicator) is *On when the current record is the last
(the next read would be EOF).
- L1..L9 (Control Level indicators) are *On when the current record has
the last combination of field(s) defined for each control level.
- Lower control indicators force *On the higher ones, that is, if L1
turns *On, L2 thru L9 turn *On too (if declared).
- LR turns *On all control level indicators.
So, for my example, I would:
1. Designate Employee as L1
2. Designate Weekday as L2.
3. Loop thru my table ordered by employee and day-of-week
4. Accumulate weekday_total and employee_total
5. Render each assistance record
6. Render weekday_total when L2 is *On
7. Render employee_total when L1 is *On
I'm going to write a module which receives a DAL query and the control
fields and returns the relevant indicators would be really useful, but I
fear I'm approaching the problem from the wrong side, using Python as if it
was RPG.
Is there a more "pythonic" way of achieving my goal?
--
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.