I am not able see the total_sales column in sqlite manager plugin of
firefox and sqlagrid of toscawidgets. But I can access the total_sales when
I use toscawidget's dbform. Any known reasons?
On Tuesday, 7 August 2012 20:56:07 UTC+5:30, jeetu wrote:
Just one minor update for future reference,
total_sales here is not a DB column here, it's just an attribute in your Python
model.
the most legit way to see total_sales in your SQLite database would be to
query for it.select sum(artist.sales) from artist where album_id=some
album.
Alternatively, a denomalized approach would be to
Just ignore the above post. I am able to get it working for adding new
artist with albums. But I am still getting some problems while updating the
albums's sales values from Turogears/toscawidgets2 interface. Let me bring
the problem to sqlalchemy level then I will post it further (if the
Just one minor update for future reference, We have to add the None
checking condition in _update_artist method as well for the update to
happen properly in the web application. But I was unable to produce the
problem in the text sqlalchemy file that I have posted in the pastebin.
My problem scenario is analogous to the following. I have an Artist table
and an Album table. Each artist can have multiple albums with sales of each
album. The artist also has a total_sales column which is basically a
cumulative of album's sales for that artist. I tried reading about
@memoized_property is a handy tool, and works simply, just clear out __dict__
of that key and it's reset.
since you're looking to work in python, the total sales are just:
@memoized_property
def total_sales(self):
# This should be the sum of all Album sales for this Artist. It
Thanks Michael for looking into my problem. I tried following your advice
but still not able to get the total_sale. Do I have to implement some
special getter/setter for memoized property. If you run the code, you will
see that nowhere 'print SETTING TOTAL_SALES' is getting executed which
is