def title_to_url(title, max_length=50):
 title = _force_unicode(title)
 title = rx_whitespace.sub('_', title)
 title = rx_notsafe.sub('', title)
 title = rx_underscore.sub('_', title)
 title = title.strip('_')
 title = title.lower()
 if (len(title) > max_length):
  title = title[:max_length]
  last_word = title.rfind('_')
  if (last_word > 0):
   title = title[:last_word]
 return (title or '_')

def title_to_url ( title , max_length = 50 ) : title = _force_unicode ( title ) title = rx_whitespace . sub ( '_' , title ) title = rx_notsafe . sub ( '' , title ) title = rx_underscore . sub ( '_' , title ) title = title . strip ( '_' ) title = title . lower ( ) if ( len ( title ) > max_length ) : title = title [ : max_length ] last_word = title . rfind ( '_' ) if ( last_word > 0 ) : title = title [ : last_word ] return ( title or '_' )
takes a string and makes it suitable for use in urls .