I'm not sure you can do that. In order to access the mysum column in the
result, you would do:
row[mysum]
Anthony
On Sunday, February 26, 2012 11:05:59 AM UTC-5, Paul wrote:
>
> In the dal I'm selecting two summed fields and adding them together,
> the column name in the set object ends up bei
I know you want to modify the query, but you could replace the string
when the rows are passed to a helper instance.
On 26 feb, 13:05, Paul wrote:
> In the dal I'm selecting two summed fields and adding them together,
> the column name in the set object ends up being called
> '(SUM(t_appointment.
Thanks Anthony,
That syntax works and I can use that to refer to the data, I could see
that a row object had an '_extra' dict for the selected expressions
but could not see that the data could be referred to be the name of
the expression 'mysum' (its in there somewhere but not sure where!!)
On Fe
>
> That syntax works and I can use that to refer to the data, I could see
> that a row object had an '_extra' dict for the selected expressions
> but could not see that the data could be referred to be the name of
> the expression 'mysum' (its in there somewhere but not sure where!!)
>
The b
One last part of the puzzle, this all works ok at the command line
with print row[mysum] but I cannot get the syntax for using this in a
view
for example:-
controller DAL query:-
def mileage():
mysum = db.t_appointment.miles_to.sum()
+db.t_appointment.miles_from.sum()
groupmm = db.t_a
The view only sees what you explicitly pass to it from the controller via
the returned dictionary, so you would need to do:
def mileage():
[snip]
return dict(rows=rows, mysum=mysum, sql=db._lastsql)
Or you could just do:
return locals()
which returns a dictionary of all the local
you need to put it in the dict so the view can see it.
On Feb 27, 2:57 pm, Paul wrote:
> One last part of the puzzle, this all works ok at the command line
> with print row[mysum] but I cannot get the syntax for using this in a
> view
>
> for example:-
>
> controller DAL query:-
> def mileage():
OK, I can get this to work in the view now, but it seems to be overly
complicated, I have one dal statement to generate some rows, but if I
want lots of sums, mins and max etc I then need to pass all these
additional objects via the dict to the view!, when surely all this
data should be just part o
I am not convinced that
rows = db().select(db.table.field1.sum() as foo)
+ {{=row.foo}}
is any simpler than
foo = db.table.field1.sum()
rows = db().select(foo)
+ {{=row[foo]}}
The latter has the advantage that does not generate conflicts at the
DB level.
As far as I know the book is almost r
>
> I am not convinced that
>
> rows = db().select(db.table.field1.sum() as foo)
> + {{=row.foo}}
>
> is any simpler than
>
> foo = db.table.field1.sum()
> rows = db().select(foo)
> + {{=row[foo]}}
>
The problem is in the latter case, you have to pass foo to the view -- not
a big deal wi
you can do:
for row in rows: row.foo = row[foo]
and then you do not have to pass it.
On Feb 27, 10:40 pm, Anthony wrote:
> > I am not convinced that
>
> > rows = db().select(db.table.field1.sum() as foo)
> > + {{=row.foo}}
>
> > is any simpler than
>
> > foo = db.table.field1.sum()
> > rows =
11 matches
Mail list logo