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

Revision 773, 4.1 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.6  2003/02/09 13:05:43  jalet
18# Internationalization continues...
19#
20# Revision 1.5  2003/02/08 22:39:46  jalet
21# --reset command line option added
22#
23# Revision 1.4  2003/02/08 09:59:59  jalet
24# Added preliminary base class for all storages
25#
26# Revision 1.3  2003/02/05 22:10:29  jalet
27# Typos
28#
29# Revision 1.2  2003/02/05 22:02:22  jalet
30# __import__ statement didn't work as expected
31#
32# Revision 1.1  2003/02/05 21:28:17  jalet
33# Initial import into CVS
34#
35#
36#
37
38class PyKotaStorageError(Exception):
39    """An exception for Quota Storage related stuff."""
40    def __init__(self, message = ""):
41        self.message = message
42        Exception.__init__(self, message)
43    def __repr__(self):
44        return self.message
45    __str__ = __repr__
46   
47class BaseStorage :   
48    """Base class for all storages."""
49    def getMatchingPrinters(self, printerpattern) :
50        """Returns the list of all printer names which match a certain pattern."""
51        pass
52           
53    def addPrinter(self, printername) :       
54        """Adds a printer to the quota storage."""
55        pass
56       
57    def getPrinterUsers(self, printername) :       
58        """Returns the list of usernames which uses a given printer."""
59        pass
60       
61    def getPrinterGroups(self, printername) :       
62        """Returns the list of groups which uses a given printer."""
63        pass
64       
65    def getPrinterPageCounter(self, printername) :
66        """Returns the last page counter value for a printer given its name."""
67        pass
68       
69    def updatePrinterPageCounter(self, printername, username, pagecount) :
70        """Updates the last page counter information for a printer given its name, last username and pagecount."""
71        pass
72       
73    def addUserPQuota(self, username, printername) :
74        """Initializes a user print quota on a printer, adds the printer and the user to the quota storage if needed."""
75        pass
76       
77    def getUPIds(self, username, printername) :   
78        """Returns a tuple (userid, printerid) given a username and a printername."""
79        pass
80       
81    def getUserPQuota(self, username, printername) :
82        """Returns the Print Quota information for a given (username, printername)."""
83        pass
84       
85    def setUserPQuota(self, username, printername, softlimit, hardlimit) :
86        """Sets soft and hard limits for a user quota on a specific printer given (username, printername)."""
87        pass
88       
89    def resetUserPQuota(self, username, printername) :   
90        """Resets the page counter to zero. Life time page counter is kept unchanged."""
91        pass
92       
93    def setDateLimit(self, username, printername, datelimit) :
94        """Sets the limit date for a soft limit to become an hard one given (username, printername)."""
95        pass
96       
97    def updateUserPQuota(self, username, printername, pagecount) :
98        """Updates the used user Quota information given (username, printername) and a job size in pages."""
99        pass
100       
101    def buyUserPQuota(self, username, printername, pagebought) :
102        """Buys pages for a given (username, printername)."""
103        pass
104       
105def openConnection(config, asadmin=0) :
106    """Returns a connection handle to the appropriate Quota Storage Database."""
107    (backend, host, database, admin, user) = config.getStorageBackend()
108    try :
109        if not backend.isalpha() :
110            # don't trust user input
111            raise ImportError
112        exec "from pykota.storages import %s as storagebackend" % backend.lower()   
113    except ImportError :
114        raise PyKotaStorageError, _("Unsupported quota storage backend %s") % backend
115    else :   
116        return getattr(storagebackend, "Storage")(host, database, (asadmin and admin) or user)
Note: See TracBrowser for help on using the browser.