Skip to content

Instantly share code, notes, and snippets.

@joestump
Created August 29, 2009 22:57
Show Gist options
  • Save joestump/177718 to your computer and use it in GitHub Desktop.
Save joestump/177718 to your computer and use it in GitHub Desktop.
class URL(models.Model):
id = models.ItemName()
url = models.Field(required=True)
views = models.NumberField(required=True, default=0)
class Meta:
connection = simpledb.SimpleDB(settings.AWS_KEY, settings.AWS_SECRET)
domain = 'shortener_url'
def save(self):
next = URLSequence.next()
shorten = BaseConverter(SHORTENER_DIGITS)
print next
short_id = shorten.from_decimal(next)
print short_id
self.id = short_id
super(URL, self).save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment