terom@20: # DeGAL - A pretty simple web image gallery terom@20: # Copyright (C) 2007 Tero Marttila terom@20: # http://marttila.de/~terom/degal/ terom@20: # terom@20: # This program is free software; you can redistribute it and/or modify terom@20: # it under the terms of the GNU General Public License as published by terom@20: # the Free Software Foundation; either version 2 of the License, or terom@20: # (at your option) any later version. terom@20: # terom@20: # This program is distributed in the hope that it will be useful, terom@20: # but WITHOUT ANY WARRANTY; without even the implied warranty of terom@20: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terom@20: # GNU General Public License for more details. terom@20: # terom@20: # You should have received a copy of the GNU General Public License terom@20: # along with this program; if not, write to the terom@20: # Free Software Foundation, Inc., terom@20: # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. terom@20: # terom@20: terom@20: import cgi terom@20: import Cookie terom@20: import os terom@20: terom@20: vars = cgi.FieldStorage() terom@20: terom@20: # the cookie with the user's current series terom@20: cookie = Cookie.SimpleCookie(os.environ.get('HTTP_COOKIE', None)) terom@20: terom@20: class token (object) : terom@20: pass terom@20: terom@20: REQUIRED_PARAM = token() terom@20: terom@20: def get_str (key, default=REQUIRED_PARAM) : terom@20: if key in vars : terom@20: return vars[key].value terom@20: elif default is REQUIRED_PARAM : terom@20: raise ValueError("Required param %s" % key) terom@20: else : terom@20: return default terom@20: terom@20: def get_int (key, default=REQUIRED_PARAM) : terom@20: if key in vars : terom@20: return int(vars[key].value) terom@20: elif default is REQUIRED_PARAM : terom@20: raise ValueError("Required param %s" % key) terom@20: else : terom@20: return default terom@20: