diff options
author | Madhusudan.C.S | 2010-07-13 17:59:47 +0530 |
---|---|---|
committer | Madhusudan.C.S | 2010-07-13 17:59:47 +0530 |
commit | e9ed5af643f96f92f2a9e97c3b751efff8727b6d (patch) | |
tree | 95df3b99b6bc3afe90dab26158bd056a82eaf20f /project/kiwipycon/utils.py | |
parent | f245bcffa2d4bd4efc6ab934db85eb76626ec599 (diff) | |
download | scipycon-e9ed5af643f96f92f2a9e97c3b751efff8727b6d.tar.gz scipycon-e9ed5af643f96f92f2a9e97c3b751efff8727b6d.tar.bz2 scipycon-e9ed5af643f96f92f2a9e97c3b751efff8727b6d.zip |
Moved the files to new Django app named scipycon and modified settings.
Diffstat (limited to 'project/kiwipycon/utils.py')
-rw-r--r-- | project/kiwipycon/utils.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/project/kiwipycon/utils.py b/project/kiwipycon/utils.py deleted file mode 100644 index 611dc62..0000000 --- a/project/kiwipycon/utils.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- -#python -import urllib -import datetime -import re -from random import randint - -#django -from django.http import HttpResponseRedirect - -def kiwipycon_quote(string, encoding="utf-8"): - """Encodes string to encoding before quoting. - """ - return urllib.quote(string.encode(encoding)) - -# from LFS -def set_message_cookie(url, msg): - """Creates response object with given url and adds message cookie with passed - message. - """ - - # We just keep the message two seconds. - max_age = 2 - expires = datetime.datetime.strftime( - datetime.datetime.utcnow() + - datetime.timedelta(seconds=max_age), "%a, %d-%b-%Y %H:%M:%S GMT") - - response = HttpResponseRedirect(url) - response.set_cookie("message", kiwipycon_quote(msg), max_age=max_age, expires=expires) - - return response - -# from django-snippets -def slugify(inStr): - removelist = ["a", "an", "as", "at", "before", "but", "by", "for","from","is", "in", "into", "like", "of", "off", "on", "onto","per","since", "than", "the", "this", "that", "to", "up", "via","with"]; - for a in removelist: - aslug = re.sub(r'\b'+a+r'\b','',inStr) - aslug = re.sub('[^\w\s-]', '', aslug).strip().lower() - aslug = re.sub('\s+', '-', aslug) - return len(aslug) > 50 and '%s-%d' % (aslug[:43], randint(100000,999999)) or aslug |