Hi Wanrong,

This is a very good question.  I had a similar problem that I ended up
solving with a non-Django solution because I was adding it to an
existing PHP-based site.  But I would like to describe what I ended up
doing to see if it would be possible to adapt it to Django.

In out case we have an site that our employees use to gather
statistics about our online application.  As in your example, the
processing of gathering the statistics is expensive so I needed a way
to intelligently cache the results in such a way that would allow the
user display the information in a sortable, filterable, pageable
widget.  (By the way, I modified an ExtJS grid for the display --
fabulous!)

Anyway, what I did was this - I used the session ID to create, in a
writable directory, a session-specific sqlite3 database with tables
that store the output of the expensive queries in tables that are
denormalized to make the end-user operations very fast and
efficient.

If the data in the session-database is too old (in my case, 15
minutes), it is regenerated.  A scheduled cron task takes care of
deleting expired session-database files.

You can tie in to Django right now given that  you use the Django
model to extract the information from your application but then you
would have to use your own interface to the temporary session database
because Django currently doesn't support multiple database
connections.  Although I think that is a work in progress.

OR you could define special Django models specifically designed to
hold the query results.  And you instantiate those based upon the
expensive queries.  If you tied those models to the user's Session
then the same code that cleaned up expired sessions would
automatically clean up those report results as well.

--gordon


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to