Hi,

I want something similar to the transaction middleware but even more
fine grained.

I'd like to  delay certain operations on a model instance while
another is occurring ... like a mutex really.

Imagine a model of a user's karma:

class Karma( model.Models ):
  user = models.ForeignKey( User )
  karma = models.IntegerField()

You can do operations that add and subtract single karma points, and
also "cash out" on karma.

I'd love to prevent cashout, upmod, & downmod from happening at the
same instant.

Polling a value in the DB (and eventually polling a value in
memcached), might be a way to go:

class KarmaLock (model.Models):
  karma = models.ForeignKey( Karma )
  locked = models.BooleanField()


start any operation like this:

karma = # some karma record
while KarmaLock.objects.filter(karma=karma)[0].locked:
  # busy loop is bad, sleeping might be worse
  pass
KarmaLock.objects.filter(karma=karma)[0].locked = True


Is the transaction middleware enough to invalidate the need for this?

Is there some DB call in the django DB api that allows for this?

Thanks!

Ivan


--~--~---------~--~----~------------~-------~--~----~
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