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

Revision 2017, 1.4 kB (checked in by jalet, 19 years ago)

Move some functions outside of the CGI to allow their use in other CGI scripts

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1# PyKota - Print Quotas for CUPS and LPRng
2#
3# (c) 2003-2004 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17#
18# $Id$
19#
20# $Log$
21# Revision 1.1  2005/01/08 17:13:01  jalet
22# Move some functions outside of the CGI to allow their use in other CGI scripts
23#
24#
25
26import os
27
28def getLanguagePreference() :
29    """Returns the preferred language."""
30    languages = os.environ.get("HTTP_ACCEPT_LANGUAGE", "")
31    langs = [l.strip().split(';')[0] for l in languages.split(",")]
32    return "%s_%s" % (langs[0], langs[0].upper())
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    return charsets[0]
Note: See TracBrowser for help on using the browser.