root / pykota / trunk / pykota / requester.py @ 773

Revision 773, 1.6 kB (checked in by jalet, 21 years ago)

Internationalization continues...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# PyKota
2#
3# PyKota : Print Quotas for CUPS
4#
5# (c) 2003 Jerome Alet <alet@librelogiciel.com>
6# You're welcome to redistribute this software under the
7# terms of the GNU General Public Licence version 2.0
8# or, at your option, any higher version.
9#
10# You can read the complete GNU GPL in the file COPYING
11# which should come along with this software, or visit
12# the Free Software Foundation's WEB site http://www.fsf.org
13#
14# $Id$
15#
16# $Log$
17# Revision 1.4  2003/02/09 13:05:43  jalet
18# Internationalization continues...
19#
20# Revision 1.3  2003/02/05 22:10:29  jalet
21# Typos
22#
23# Revision 1.2  2003/02/05 22:02:22  jalet
24# __import__ statement didn't work as expected
25#
26# Revision 1.1  2003/02/05 21:28:17  jalet
27# Initial import into CVS
28#
29#
30#
31
32class PyKotaRequesterError(Exception):
33    """An exception for Requester related stuff."""
34    def __init__(self, message = ""):
35        self.message = message
36        Exception.__init__(self, message)
37    def __repr__(self):
38        return self.message
39    __str__ = __repr__
40   
41def openRequester(config, printername) :
42    """Returns a connection handle to the appropriate requester."""
43    backend = config.getRequesterBackend(printername)
44    try :
45        if not backend.isalpha() :
46            # don't trust user input
47            raise ImportError
48        exec "from pykota.requesters import %s as requesterbackend" % backend.lower()   
49    except ImportError :
50        raise PyKotaRequesterError, _("Unsupported requester backend %s") % backend
51    else :   
52        return getattr(requesterbackend, "Requester")(config, printername)
Note: See TracBrowser for help on using the browser.