Skip to content

Instantly share code, notes, and snippets.

@joestump
Created August 29, 2009 21:38
Show Gist options
  • Save joestump/177684 to your computer and use it in GitHub Desktop.
Save joestump/177684 to your computer and use it in GitHub Desktop.
class URLSequence(models.Model):
id = models.ItemName()
urls = models.NumberField(required=True, default=0)
class Meta:
connection = simpledb.SimpleDB(settings.AWS_KEY, settings.AWS_SECRET)
domain = 'shortener_url'
@staticmethod
def id():
id = '%s_sequence' % settings.AWS_KEY
try:
seq = URLSequence.objects.get(id)
except Exception:
seq = URLSequence()
seq.id = id
seq.urls = 0
seq.save()
seq.urls = int(seq.urls) + 1
seq.save()
return int(seq.urls)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment