Django

Code

Show
Ignore:
Timestamp:
07/31/08 15:47:53 (5 months ago)
Author:
lukeplant
Message:

Fixed #7723 - implemented a secure password reset form that uses a token and prompts user for new password.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/utils/http.py

    r6634 r8162  
    6666    rfcdate = formatdate(epoch_seconds) 
    6767    return '%s GMT' % rfcdate[:25] 
     68 
     69# Base 36 functions: useful for generating compact URLs 
     70 
     71def base36_to_int(s): 
     72    """ 
     73    Convertd a base 36 string to an integer 
     74    """ 
     75    return int(s, 36) 
     76 
     77def int_to_base36(i): 
     78    """ 
     79    Converts an integer to a base36 string 
     80    """ 
     81    digits = "0123456789abcdefghijklmnopqrstuvwxyz" 
     82    factor = 0 
     83    # Find starting factor 
     84    while True: 
     85        factor += 1 
     86        if i < 36 ** factor: 
     87            factor -= 1 
     88            break 
     89    base36 = [] 
     90    # Construct base36 representation 
     91    while factor >= 0: 
     92        j = 36 ** factor 
     93        base36.append(digits[i / j]) 
     94        i = i % j 
     95        factor -= 1 
     96    return ''.join(base36)