On Sun, 2008-10-19 at 13:24 -0700, truebosko wrote: > Hi there, > > So I spent the last few hours trying to get a ProgressBar Upload > handler working > > What it does: User uploads a file, when they hit the submit button, > javascript is called and begins polling the server (a django view) for > progress. Progress is stored in a cache_key, very simple idea. > > The Problem: The cache key is not being written to the database until > AFTER the upload is complete. I watched the database and the key did > not show up in it until the upload was complete. Which makes it > totally useless.
As soon as you see something not being visible in the database to another process until later than you expect, you have to think about transactions and I'll wager that's almost certainly what's going on here. Since the upload handler is writing something to the database, it won't commit the transaction until the upload is finished, which will mean that any other writes done by the same connection won't be visible either. Django's caching framework doesn't put caching writes are in separate transactions to the rest of the view (that would require multiple connections for some backends and be awfully complicated). The normal use-case for caching is on the granularity of per-view and you're wanting something finer: different points within the same view run being visible to other processes / views. The main stumbling block is that you've chosen to use the database cache here and the database is also being used by the view for other things. The solution is "don't do that". Use memcache (which is really easy to set up). Or write your own modification of the database cache backend that uses an entirely separate connection. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---