root / pykota / trunk / pykota / storages / sql.py @ 1451

Revision 1451, 25.3 kB (checked in by jalet, 20 years ago)

pkpgcounter : comments
pkprinters : when --add is used, existing printers are now skipped.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1# PyKota
2# -*- coding: ISO-8859-15 -*-
3#
4# PyKota : Print Quotas for CUPS and LPRng
5#
6# (c) 2003-2004 Jerome Alet <alet@librelogiciel.com>
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20#
21# $Id$
22#
23# $Log$
24# Revision 1.38  2004/05/06 12:37:47  jalet
25# pkpgcounter : comments
26# pkprinters : when --add is used, existing printers are now skipped.
27#
28# Revision 1.37  2004/02/23 22:53:21  jalet
29# Don't retrieve data when it's not needed, to avoid database queries
30#
31# Revision 1.36  2004/02/04 13:24:41  jalet
32# pkprinters can now remove printers from printers groups.
33#
34# Revision 1.35  2004/02/04 11:17:00  jalet
35# pkprinters command line tool added.
36#
37# Revision 1.34  2004/02/02 22:44:16  jalet
38# Preliminary work on Relationnal Database Independance via DB-API 2.0
39#
40#
41#
42
43from pykota.storage import PyKotaStorageError,BaseStorage,StorageObject,StorageUser,StorageGroup,StoragePrinter,StorageJob,StorageLastJob,StorageUserPQuota,StorageGroupPQuota
44
45class SQLStorage :
46    def getAllUsersNames(self) :   
47        """Extracts all user names."""
48        usernames = []
49        result = self.doSearch("SELECT username FROM users")
50        if result :
51            usernames = [record["username"] for record in result]
52        return usernames
53       
54    def getAllGroupsNames(self) :   
55        """Extracts all group names."""
56        groupnames = []
57        result = self.doSearch("SELECT groupname FROM groups")
58        if result :
59            groupnames = [record["groupname"] for record in result]
60        return groupnames
61       
62    def getUserFromBackend(self, username) :   
63        """Extracts user information given its name."""
64        user = StorageUser(self, username)
65        result = self.doSearch("SELECT * FROM users WHERE username=%s LIMIT 1" % self.doQuote(username))
66        if result :
67            fields = result[0]
68            user.ident = fields.get("id")
69            user.Name = fields.get("username", username)
70            user.LimitBy = fields.get("limitby")
71            user.AccountBalance = fields.get("balance")
72            user.LifeTimePaid = fields.get("lifetimepaid")
73            user.Email = fields.get("email")
74            user.Exists = 1
75        return user
76       
77    def getGroupFromBackend(self, groupname) :   
78        """Extracts group information given its name."""
79        group = StorageGroup(self, groupname)
80        result = self.doSearch("SELECT * FROM groups WHERE groupname=%s LIMIT 1" % self.doQuote(groupname))
81        if result :
82            fields = result[0]
83            group.ident = fields.get("id")
84            group.Name = fields.get("groupname", groupname)
85            group.LimitBy = fields.get("limitby")
86            result = self.doSearch("SELECT SUM(balance) AS balance, SUM(lifetimepaid) AS lifetimepaid FROM users WHERE id IN (SELECT userid FROM groupsmembers WHERE groupid=%s)" % self.doQuote(group.ident))
87            if result :
88                fields = result[0]
89                group.AccountBalance = fields.get("balance")
90                group.LifeTimePaid = fields.get("lifetimepaid")
91            group.Exists = 1
92        return group
93       
94    def getPrinterFromBackend(self, printername) :       
95        """Extracts printer information given its name."""
96        printer = StoragePrinter(self, printername)
97        result = self.doSearch("SELECT * FROM printers WHERE printername=%s LIMIT 1" % self.doQuote(printername))
98        if result :
99            fields = result[0]
100            printer.ident = fields.get("id")
101            printer.Name = fields.get("printername", printername)
102            printer.PricePerJob = fields.get("priceperjob")
103            printer.PricePerPage = fields.get("priceperpage")
104            printer.Exists = 1
105        return printer   
106       
107    def getUserPQuotaFromBackend(self, user, printer) :       
108        """Extracts a user print quota."""
109        userpquota = StorageUserPQuota(self, user, printer)
110        if printer.Exists and user.Exists :
111            result = self.doSearch("SELECT id, lifepagecounter, pagecounter, softlimit, hardlimit, datelimit FROM userpquota WHERE userid=%s AND printerid=%s" % (self.doQuote(user.ident), self.doQuote(printer.ident)))
112            if result :
113                fields = result[0]
114                userpquota.ident = fields.get("id")
115                userpquota.PageCounter = fields.get("pagecounter")
116                userpquota.LifePageCounter = fields.get("lifepagecounter")
117                userpquota.SoftLimit = fields.get("softlimit")
118                userpquota.HardLimit = fields.get("hardlimit")
119                userpquota.DateLimit = fields.get("datelimit")
120                userpquota.Exists = 1
121        return userpquota
122       
123    def getGroupPQuotaFromBackend(self, group, printer) :       
124        """Extracts a group print quota."""
125        grouppquota = StorageGroupPQuota(self, group, printer)
126        if group.Exists :
127            result = self.doSearch("SELECT id, softlimit, hardlimit, datelimit FROM grouppquota WHERE groupid=%s AND printerid=%s" % (self.doQuote(group.ident), self.doQuote(printer.ident)))
128            if result :
129                fields = result[0]
130                grouppquota.ident = fields.get("id")
131                grouppquota.SoftLimit = fields.get("softlimit")
132                grouppquota.HardLimit = fields.get("hardlimit")
133                grouppquota.DateLimit = fields.get("datelimit")
134                result = self.doSearch("SELECT SUM(lifepagecounter) AS lifepagecounter, SUM(pagecounter) AS pagecounter FROM userpquota WHERE printerid=%s AND userid IN (SELECT userid FROM groupsmembers WHERE groupid=%s)" % (self.doQuote(printer.ident), self.doQuote(group.ident)))
135                if result :
136                    fields = result[0]
137                    grouppquota.PageCounter = fields.get("pagecounter")
138                    grouppquota.LifePageCounter = fields.get("lifepagecounter")
139                grouppquota.Exists = 1
140        return grouppquota
141       
142    def getPrinterLastJobFromBackend(self, printer) :       
143        """Extracts a printer's last job information."""
144        lastjob = StorageLastJob(self, printer)
145        result = self.doSearch("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize, jobprice, filename, title, copies, options, jobdate FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printer.ident))
146        if result :
147            fields = result[0]
148            lastjob.ident = fields.get("id")
149            lastjob.JobId = fields.get("jobid")
150            lastjob.UserName = fields.get("username")
151            lastjob.PrinterPageCounter = fields.get("pagecounter")
152            lastjob.JobSize = fields.get("jobsize")
153            lastjob.JobPrice = fields.get("jobprice")
154            lastjob.JobAction = fields.get("action")
155            lastjob.JobFileName = fields.get("filename")
156            lastjob.JobTitle = fields.get("title")
157            lastjob.JobCopies = fields.get("copies")
158            lastjob.JobOptions = fields.get("options")
159            lastjob.JobDate = fields.get("jobdate")
160            lastjob.Exists = 1
161        return lastjob
162           
163    def getGroupMembersFromBackend(self, group) :       
164        """Returns the group's members list."""
165        groupmembers = []
166        result = self.doSearch("SELECT * FROM groupsmembers JOIN users ON groupsmembers.userid=users.id WHERE groupid=%s" % self.doQuote(group.ident))
167        if result :
168            for record in result :
169                user = StorageUser(self, record.get("username"))
170                user.ident = record.get("userid")
171                user.LimitBy = record.get("limitby")
172                user.AccountBalance = record.get("balance")
173                user.LifeTimePaid = record.get("lifetimepaid")
174                user.Email = record.get("email")
175                user.Exists = 1
176                groupmembers.append(user)
177                self.cacheEntry("USERS", user.Name, user)
178        return groupmembers       
179       
180    def getUserGroupsFromBackend(self, user) :       
181        """Returns the user's groups list."""
182        groups = []
183        result = self.doSearch("SELECT groupname FROM groupsmembers JOIN groups ON groupsmembers.groupid=groups.id WHERE userid=%s" % self.doQuote(user.ident))
184        if result :
185            for record in result :
186                groups.append(self.getGroup(record.get("groupname")))
187        return groups       
188       
189    def getParentPrintersFromBackend(self, printer) :   
190        """Get all the printer groups this printer is a member of."""
191        pgroups = []
192        result = self.doSearch("SELECT groupid,printername FROM printergroupsmembers JOIN printers ON groupid=id WHERE printerid=%s" % self.doQuote(printer.ident))
193        if result :
194            for record in result :
195                if record["groupid"] != printer.ident : # in case of integrity violation
196                    parentprinter = self.getPrinter(record.get("printername"))
197                    if parentprinter.Exists :
198                        pgroups.append(parentprinter)
199        return pgroups
200       
201    def getMatchingPrinters(self, printerpattern) :
202        """Returns the list of all printers for which name matches a certain pattern."""
203        printers = []
204        # We 'could' do a SELECT printername FROM printers WHERE printername LIKE ...
205        # but we don't because other storages semantics may be different, so every
206        # storage should use fnmatch to match patterns and be storage agnostic
207        result = self.doSearch("SELECT * FROM printers")
208        if result :
209            for record in result :
210                if self.tool.matchString(record["printername"], printerpattern.split(",")) :
211                    printer = StoragePrinter(self, record["printername"])
212                    printer.ident = record.get("id")
213                    printer.PricePerJob = record.get("priceperjob")
214                    printer.PricePerPage = record.get("priceperpage")
215                    printer.Exists = 1
216                    printers.append(printer)
217                    self.cacheEntry("PRINTERS", printer.Name, printer)
218        return printers       
219       
220    def getPrinterUsersAndQuotas(self, printer, names=["*"]) :       
221        """Returns the list of users who uses a given printer, along with their quotas."""
222        usersandquotas = []
223        result = self.doSearch("SELECT users.id as uid,username,balance,lifetimepaid,limitby,email,userpquota.id,lifepagecounter,pagecounter,softlimit,hardlimit,datelimit FROM users JOIN userpquota ON users.id=userpquota.userid AND printerid=%s ORDER BY username ASC" % self.doQuote(printer.ident))
224        if result :
225            for record in result :
226                if self.tool.matchString(record.get("username"), names) :
227                    user = StorageUser(self, record.get("username"))
228                    user.ident = record.get("uid")
229                    user.LimitBy = record.get("limitby")
230                    user.AccountBalance = record.get("balance")
231                    user.LifeTimePaid = record.get("lifetimepaid")
232                    user.Email = record.get("email") 
233                    user.Exists = 1
234                    userpquota = StorageUserPQuota(self, user, printer)
235                    userpquota.ident = record.get("id")
236                    userpquota.PageCounter = record.get("pagecounter")
237                    userpquota.LifePageCounter = record.get("lifepagecounter")
238                    userpquota.SoftLimit = record.get("softlimit")
239                    userpquota.HardLimit = record.get("hardlimit")
240                    userpquota.DateLimit = record.get("datelimit")
241                    userpquota.Exists = 1
242                    usersandquotas.append((user, userpquota))
243                    self.cacheEntry("USERS", user.Name, user)
244                    self.cacheEntry("USERPQUOTAS", "%s@%s" % (user.Name, printer.Name), userpquota)
245        return usersandquotas
246               
247    def getPrinterGroupsAndQuotas(self, printer, names=["*"]) :       
248        """Returns the list of groups which uses a given printer, along with their quotas."""
249        groupsandquotas = []
250        result = self.doSearch("SELECT groupname FROM groups JOIN grouppquota ON groups.id=grouppquota.groupid AND printerid=%s ORDER BY groupname ASC" % self.doQuote(printer.ident))
251        if result :
252            for record in result :
253                if self.tool.matchString(record.get("groupname"), names) :
254                    group = self.getGroup(record.get("groupname"))
255                    grouppquota = self.getGroupPQuota(group, printer)
256                    groupsandquotas.append((group, grouppquota))
257        return groupsandquotas
258       
259    def addPrinter(self, printername) :       
260        """Adds a printer to the quota storage, returns it."""
261        self.doModify("INSERT INTO printers (printername) VALUES (%s)" % self.doQuote(printername))
262        return self.getPrinter(printername)
263       
264    def addUser(self, user) :       
265        """Adds a user to the quota storage, returns its id."""
266        self.doModify("INSERT INTO users (username, limitby, balance, lifetimepaid, email) VALUES (%s, %s, %s, %s, %s)" % (self.doQuote(user.Name), self.doQuote(user.LimitBy), self.doQuote(user.AccountBalance), self.doQuote(user.LifeTimePaid), self.doQuote(user.Email)))
267        return self.getUser(user.Name)
268       
269    def addGroup(self, group) :       
270        """Adds a group to the quota storage, returns its id."""
271        self.doModify("INSERT INTO groups (groupname, limitby) VALUES (%s, %s)" % (self.doQuote(group.Name), self.doQuote(group.LimitBy)))
272        return self.getGroup(group.Name)
273
274    def addUserToGroup(self, user, group) :   
275        """Adds an user to a group."""
276        result = self.doSearch("SELECT COUNT(*) AS mexists FROM groupsmembers WHERE groupid=%s AND userid=%s" % (self.doQuote(group.ident), self.doQuote(user.ident)))
277        try :
278            mexists = int(result[0].get("mexists"))
279        except (IndexError, TypeError) :   
280            mexists = 0
281        if not mexists :   
282            self.doModify("INSERT INTO groupsmembers (groupid, userid) VALUES (%s, %s)" % (self.doQuote(group.ident), self.doQuote(user.ident)))
283           
284    def addUserPQuota(self, user, printer) :
285        """Initializes a user print quota on a printer."""
286        self.doModify("INSERT INTO userpquota (userid, printerid) VALUES (%s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident)))
287        return self.getUserPQuota(user, printer)
288       
289    def addGroupPQuota(self, group, printer) :
290        """Initializes a group print quota on a printer."""
291        self.doModify("INSERT INTO grouppquota (groupid, printerid) VALUES (%s, %s)" % (self.doQuote(group.ident), self.doQuote(printer.ident)))
292        return self.getGroupPQuota(group, printer)
293       
294    def writePrinterPrices(self, printer) :   
295        """Write the printer's prices back into the storage."""
296        self.doModify("UPDATE printers SET priceperpage=%s, priceperjob=%s WHERE id=%s" % (self.doQuote(printer.PricePerPage), self.doQuote(printer.PricePerJob), self.doQuote(printer.ident)))
297       
298    def writeUserLimitBy(self, user, limitby) :   
299        """Sets the user's limiting factor."""
300        self.doModify("UPDATE users SET limitby=%s WHERE id=%s" % (self.doQuote(limitby), self.doQuote(user.ident)))
301       
302    def writeGroupLimitBy(self, group, limitby) :   
303        """Sets the group's limiting factor."""
304        self.doModify("UPDATE groups SET limitby=%s WHERE id=%s" % (self.doQuote(limitby), self.doQuote(group.ident)))
305       
306    def writeUserPQuotaDateLimit(self, userpquota, datelimit) :   
307        """Sets the date limit permanently for a user print quota."""
308        self.doModify("UPDATE userpquota SET datelimit=%s WHERE id=%s" % (self.doQuote(datelimit), self.doQuote(userpquota.ident)))
309           
310    def writeGroupPQuotaDateLimit(self, grouppquota, datelimit) :   
311        """Sets the date limit permanently for a group print quota."""
312        self.doModify("UPDATE grouppquota SET datelimit=%s WHERE id=%s" % (self.doQuote(datelimit), self.doQuote(grouppquota.ident)))
313       
314    def increaseUserPQuotaPagesCounters(self, userpquota, nbpages) :   
315        """Increase page counters for a user print quota."""
316        self.doModify("UPDATE userpquota SET pagecounter=pagecounter+%s,lifepagecounter=lifepagecounter+%s WHERE id=%s" % (self.doQuote(nbpages), self.doQuote(nbpages), self.doQuote(userpquota.ident)))
317       
318    def writeUserPQuotaPagesCounters(self, userpquota, newpagecounter, newlifepagecounter) :   
319        """Sets the new page counters permanently for a user print quota."""
320        self.doModify("UPDATE userpquota SET pagecounter=%s,lifepagecounter=%s WHERE id=%s" % (self.doQuote(newpagecounter), self.doQuote(newlifepagecounter), self.doQuote(userpquota.ident)))
321       
322    def decreaseUserAccountBalance(self, user, amount) :   
323        """Decreases user's account balance from an amount."""
324        self.doModify("UPDATE users SET balance=balance-%s WHERE id=%s" % (self.doQuote(amount), self.doQuote(user.ident)))
325       
326    def writeUserAccountBalance(self, user, newbalance, newlifetimepaid=None) :   
327        """Sets the new account balance and eventually new lifetime paid."""
328        if newlifetimepaid is not None :
329            self.doModify("UPDATE users SET balance=%s, lifetimepaid=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(newlifetimepaid), self.doQuote(user.ident)))
330        else :   
331            self.doModify("UPDATE users SET balance=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(user.ident)))
332           
333    def writeLastJobSize(self, lastjob, jobsize, jobprice) :       
334        """Sets the last job's size permanently."""
335        self.doModify("UPDATE jobhistory SET jobsize=%s, jobprice=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(lastjob.ident)))
336       
337    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) :   
338        """Adds a job in a printer's history."""
339        if (not self.disablehistory) or (not printer.LastJob.Exists) :
340            if jobsize is not None :
341                self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options)))
342            else :   
343                self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, filename, title, copies, options) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options)))
344        else :       
345            # here we explicitly want to reset jobsize to NULL if needed
346            self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, jobprice=%s, filename=%s, title=%s, copies=%s, options=%s, jobdate=now() WHERE id=%s" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(printer.LastJob.ident)))
347           
348    def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) :
349        """Sets soft and hard limits for a user quota."""
350        self.doModify("UPDATE userpquota SET softlimit=%s, hardlimit=%s, datelimit=NULL WHERE id=%s" % (self.doQuote(softlimit), self.doQuote(hardlimit), self.doQuote(userpquota.ident)))
351       
352    def writeGroupPQuotaLimits(self, grouppquota, softlimit, hardlimit) :
353        """Sets soft and hard limits for a group quota on a specific printer."""
354        self.doModify("UPDATE grouppquota SET softlimit=%s, hardlimit=%s, datelimit=NULL WHERE id=%s" % (self.doQuote(softlimit), self.doQuote(hardlimit), self.doQuote(grouppquota.ident)))
355
356    def writePrinterToGroup(self, pgroup, printer) :
357        """Puts a printer into a printer group."""
358        children = []
359        result = self.doSearch("SELECT printerid FROM printergroupsmembers WHERE groupid=%s" % self.doQuote(pgroup.ident))
360        if result :
361            for record in result :
362                children.append(record.get("printerid")) # TODO : put this into the database integrity rules
363        if printer.ident not in children :       
364            self.doModify("INSERT INTO printergroupsmembers (groupid, printerid) VALUES (%s, %s)" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident)))
365       
366    def removePrinterFromGroup(self, pgroup, printer) :
367        """Removes a printer from a printer group."""
368        self.doModify("DELETE FROM printergroupsmembers WHERE groupid=%s AND printerid=%s" % (self.doQuote(pgroup.ident), self.doQuote(printer.ident)))
369       
370    def retrieveHistory(self, user=None, printer=None, datelimit=None, limit=100) :   
371        """Retrieves all print jobs for user on printer (or all) before date, limited to first 100 results."""
372        query = "SELECT jobhistory.*,username,printername FROM jobhistory,users,printers WHERE users.id=userid AND printers.id=printerid"
373        where = []
374        if (user is not None) and user.Exists :
375            where.append("userid=%s" % self.doQuote(user.ident))
376        if (printer is not None) and printer.Exists :
377            where.append("printerid=%s" % self.doQuote(printer.ident))
378        if datelimit is not None :   
379            where.append("jobdate<=%s" % self.doQuote(datelimit))
380        if where :   
381            query += " AND %s" % " AND ".join(where)
382        query += " ORDER BY id DESC"
383        if limit :
384            query += " LIMIT %s" % self.doQuote(int(limit))
385        jobs = []   
386        result = self.doSearch(query)   
387        if result :
388            for fields in result :
389                job = StorageJob(self)
390                job.ident = fields.get("id")
391                job.JobId = fields.get("jobid")
392                job.PrinterPageCounter = fields.get("pagecounter")
393                job.JobSize = fields.get("jobsize")
394                job.JobPrice = fields.get("jobprice")
395                job.JobAction = fields.get("action")
396                job.JobFileName = fields.get("filename")
397                job.JobTitle = fields.get("title")
398                job.JobCopies = fields.get("copies")
399                job.JobOptions = fields.get("options")
400                job.JobDate = fields.get("jobdate")
401                job.UserName = fields.get("username")
402                job.PrinterName = fields.get("printername")
403                job.Exists = 1
404                jobs.append(job)
405        return jobs
406       
407    def deleteUser(self, user) :   
408        """Completely deletes an user from the Quota Storage."""
409        # TODO : What should we do if we delete the last person who used a given printer ?
410        # TODO : we can't reassign the last job to the previous one, because next user would be
411        # TODO : incorrectly charged (overcharged).
412        for q in [ 
413                    "DELETE FROM groupsmembers WHERE userid=%s" % self.doQuote(user.ident),
414                    "DELETE FROM jobhistory WHERE userid=%s" % self.doQuote(user.ident),
415                    "DELETE FROM userpquota WHERE userid=%s" % self.doQuote(user.ident),
416                    "DELETE FROM users WHERE id=%s" % self.doQuote(user.ident),
417                  ] :
418            self.doModify(q)
419       
420    def deleteGroup(self, group) :   
421        """Completely deletes a group from the Quota Storage."""
422        for q in [
423                   "DELETE FROM groupsmembers WHERE groupid=%s" % self.doQuote(group.ident),
424                   "DELETE FROM grouppquota WHERE groupid=%s" % self.doQuote(group.ident),
425                   "DELETE FROM groups WHERE id=%s" % self.doQuote(group.ident),
426                 ] : 
427            self.doModify(q)
428           
429    def deletePrinter(self, printer) :   
430        """Completely deletes a printer from the Quota Storage."""
431        for q in [ 
432                    "DELETE FROM printergroupsmembers WHERE groupid=%s OR printerid=%s" % (self.doQuote(printer.ident), self.doQuote(printer.ident)),
433                    "DELETE FROM jobhistory WHERE printerid=%s" % self.doQuote(printer.ident),
434                    "DELETE FROM grouppquota WHERE printerid=%s" % self.doQuote(printer.ident),
435                    "DELETE FROM userpquota WHERE printerid=%s" % self.doQuote(printer.ident),
436                    "DELETE FROM printers WHERE id=%s" % self.doQuote(printer.ident),
437                  ] :
438            self.doModify(q)
439       
Note: See TracBrowser for help on using the browser.