author | terom |
Wed, 16 Jan 2008 16:28:00 +0000 | |
changeset 20 | 6c774496bb00 |
child 23 | 10841abbc01f |
permissions | -rw-r--r-- |
20
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
1 |
# DeGAL - A pretty simple web image gallery |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
2 |
# Copyright (C) 2007 Tero Marttila |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
3 |
# http://marttila.de/~terom/degal/ |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
4 |
# |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
5 |
# This program is free software; you can redistribute it and/or modify |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
6 |
# it under the terms of the GNU General Public License as published by |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
7 |
# the Free Software Foundation; either version 2 of the License, or |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
8 |
# (at your option) any later version. |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
9 |
# |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
10 |
# This program is distributed in the hope that it will be useful, |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
13 |
# GNU General Public License for more details. |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
14 |
# |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
15 |
# You should have received a copy of the GNU General Public License |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
16 |
# along with this program; if not, write to the |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
17 |
# Free Software Foundation, Inc., |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
18 |
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
19 |
# |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
20 |
|
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
21 |
import cgi |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
22 |
import Cookie |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
23 |
import os |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
24 |
|
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
25 |
vars = cgi.FieldStorage() |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
26 |
|
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
27 |
# the cookie with the user's current series |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
28 |
cookie = Cookie.SimpleCookie(os.environ.get('HTTP_COOKIE', None)) |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
29 |
|
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
30 |
class token (object) : |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
31 |
pass |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
32 |
|
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
33 |
REQUIRED_PARAM = token() |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
34 |
|
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
35 |
def get_str (key, default=REQUIRED_PARAM) : |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
36 |
if key in vars : |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
37 |
return vars[key].value |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
38 |
elif default is REQUIRED_PARAM : |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
39 |
raise ValueError("Required param %s" % key) |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
40 |
else : |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
41 |
return default |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
42 |
|
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
43 |
def get_int (key, default=REQUIRED_PARAM) : |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
44 |
if key in vars : |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
45 |
return int(vars[key].value) |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
46 |
elif default is REQUIRED_PARAM : |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
47 |
raise ValueError("Required param %s" % key) |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
48 |
else : |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
49 |
return default |
6c774496bb00
a rather silly shelve-based tagging thing, commiting before I scrap the code and start over with SQLite
terom
parents:
diff
changeset
|
50 |