root / pykota / trunk / pykota / cgifuncs.py @ 3184

Revision 3184, 1.5 kB (checked in by jerome, 17 years ago)

Added some docstrings.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# PyKota - Print Quotas for CUPS and LPRng
2#
3# (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet <alet@librelogiciel.com>
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17#
18# $Id$
19#
20#
21
22"""This module defines some helper functions to use in CGI scripts."""
23
24import sys
25import os
26
27def getLanguagePreference() :
28    """Returns the preferred language."""
29    languages = os.environ.get("HTTP_ACCEPT_LANGUAGE", "")
30    langs = [l.strip().split(';')[0] for l in languages.split(",")]
31    #sys.stderr.write("Languages preferences : %s\n" % langs)
32    return langs[0].replace("-", "_")
33   
34def getCharsetPreference() :
35    """Returns the preferred charset."""
36    charsets = os.environ.get("HTTP_ACCEPT_CHARSET", "UTF-8")
37    charsets = [l.strip().split(';')[0] for l in charsets.split(",")]
38    #sys.stderr.write("Charsets preferences : %s\n" % charsets)
39    return charsets[0]
Note: See TracBrowser for help on using the browser.