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

Revision 780, 1.7 kB (checked in by jalet, 21 years ago)

External requester should be ok (untested)
New syntax for configuration file wrt requesters

  • 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.5  2003/02/10 00:42:17  jalet
18# External requester should be ok (untested)
19# New syntax for configuration file wrt requesters
20#
21# Revision 1.4  2003/02/09 13:05:43  jalet
22# Internationalization continues...
23#
24# Revision 1.3  2003/02/05 22:10:29  jalet
25# Typos
26#
27# Revision 1.2  2003/02/05 22:02:22  jalet
28# __import__ statement didn't work as expected
29#
30# Revision 1.1  2003/02/05 21:28:17  jalet
31# Initial import into CVS
32#
33#
34#
35
36class PyKotaRequesterError(Exception):
37    """An exception for Requester related stuff."""
38    def __init__(self, message = ""):
39        self.message = message
40        Exception.__init__(self, message)
41    def __repr__(self):
42        return self.message
43    __str__ = __repr__
44   
45def openRequester(config, printername) :
46    """Returns a connection handle to the appropriate requester."""
47    (backend, args) = config.getRequesterBackend(printername)
48    try :
49        if not backend.isalpha() :
50            # don't trust user input
51            raise ImportError
52        exec "from pykota.requesters import %s as requesterbackend" % backend.lower()   
53    except ImportError :
54        raise PyKotaRequesterError, _("Unsupported requester backend %s") % backend
55    else :   
56        return getattr(requesterbackend, "Requester")(config, printername, args)
Note: See TracBrowser for help on using the browser.