Skip to content
Permalink
Browse files

Do not use a lmabda for base36 function

  • Loading branch information
Fantomas42 committed Apr 7, 2014
1 parent 28ac367 commit 05c7dd8d04c5fd563dc5167687c13b53484ca92f
Showing with 12 additions and 5 deletions.
  1. +12 −5 zinnia/url_shortener/backends/default.py
@@ -1,16 +1,23 @@
"""Default URL shortener backend for Zinnia"""
import math
import string

from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse

from zinnia.settings import PROTOCOL

base36 = lambda x: ''.join(
[(string.digits + string.ascii_uppercase)[(x // 36 ** i) % 36]
for i in range(int(math.log(x, 36)), -1, -1)]
)
BASE36_ALPHABET = string.digits + string.ascii_uppercase


def base36(value):
"""
Encode int to base 36.
"""
result = ''
while value:
value, i = divmod(value, 36)
result = BASE36_ALPHABET[i] + result
return result


def backend(entry):

0 comments on commit 05c7dd8

Please sign in to comment.
You can’t perform that action at this time.