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

Revision 1358, 24.9 kB (checked in by jalet, 20 years ago)

Don't retrieve data when it's not needed, to avoid database queries

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