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

Revision 1368, 24.5 kB (checked in by jalet, 20 years ago)

Hopefully the final fix for groups (users and printers)

  • 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.48  2004/02/27 13:50:12  jalet
25# Hopefully the final fix for groups (users and printers)
26#
27# Revision 1.47  2004/02/27 09:30:33  jalet
28# datelimit wasn't reset when modifying soft and hard limits with the LDAP backend
29#
30# Revision 1.46  2004/02/26 14:18:07  jalet
31# Should fix the remaining bugs wrt printers groups and users groups.
32#
33# Revision 1.45  2004/02/26 10:40:40  jalet
34# Fixed nested printer groups accounting.
35#
36# Revision 1.44  2004/02/25 19:09:24  jalet
37# Fix for LDAP problem when job price was 0.
38#
39# Revision 1.43  2004/02/25 12:36:34  jalet
40# Avoids a database query even if caching was disabled.
41#
42# Revision 1.42  2004/02/23 22:53:21  jalet
43# Don't retrieve data when it's not needed, to avoid database queries
44#
45# Revision 1.41  2004/02/04 17:12:33  jalet
46# Removing a printer from a printers group should work now.
47#
48# Revision 1.40  2004/02/04 13:24:41  jalet
49# pkprinters can now remove printers from printers groups.
50#
51# Revision 1.39  2004/02/04 11:16:59  jalet
52# pkprinters command line tool added.
53#
54# Revision 1.38  2004/01/12 22:43:40  jalet
55# New formula to compute a job's price
56#
57# Revision 1.37  2004/01/12 14:35:01  jalet
58# Printing history added to CGI script.
59#
60# Revision 1.36  2004/01/10 09:44:02  jalet
61# Fixed potential accuracy problem if a user printed on several printers at
62# the very same time.
63#
64# Revision 1.35  2004/01/08 16:33:27  jalet
65# Additionnal check to not create a circular printers group.
66#
67# Revision 1.34  2004/01/08 16:24:49  jalet
68# edpykota now supports adding printers to printer groups.
69#
70# Revision 1.33  2004/01/08 14:10:32  jalet
71# Copyright year changed.
72#
73# Revision 1.32  2004/01/06 16:02:57  jalet
74# This time printer groups caching works.
75#
76# Revision 1.31  2004/01/06 15:51:24  jalet
77# Fixed caching of printer groups
78#
79# Revision 1.30  2004/01/06 14:24:59  jalet
80# Printer groups should be cached now, if caching is enabled.
81#
82# Revision 1.29  2003/12/27 16:49:25  uid67467
83# Should be ok now.
84#
85# Revision 1.28  2003/11/25 23:46:40  jalet
86# Don't try to verify if module name is valid, Python does this better than us.
87#
88# Revision 1.27  2003/11/23 19:01:36  jalet
89# Job price added to history
90#
91# Revision 1.26  2003/11/21 14:28:45  jalet
92# More complete job history.
93#
94# Revision 1.25  2003/10/08 21:12:27  jalet
95# Do not cache anymore entries which don't exist.
96#
97# Revision 1.24  2003/10/07 22:06:05  jalet
98# Preliminary code to disable job history
99#
100# Revision 1.23  2003/10/07 09:07:28  jalet
101# Character encoding added to please latest version of Python
102#
103# Revision 1.22  2003/10/06 13:12:27  jalet
104# More work on caching
105#
106# Revision 1.21  2003/10/03 09:02:20  jalet
107# Logs cache store actions too
108#
109# Revision 1.20  2003/10/02 20:23:18  jalet
110# Storage caching mechanism added.
111#
112# Revision 1.19  2003/07/16 21:53:07  jalet
113# Really big modifications wrt new configuration file's location and content.
114#
115# Revision 1.18  2003/07/07 08:33:18  jalet
116# Bug fix due to a typo in LDAP code
117#
118# Revision 1.17  2003/07/05 07:46:50  jalet
119# The previous bug fix was incomplete.
120#
121# Revision 1.16  2003/06/25 19:52:31  jalet
122# Should be ready for testing :-)
123#
124# Revision 1.15  2003/06/25 14:10:58  jalet
125# Exception raising for now.
126#
127# Revision 1.14  2003/06/25 14:10:01  jalet
128# Hey, it may work (edpykota --reset excepted) !
129#
130# Revision 1.13  2003/06/10 16:37:54  jalet
131# Deletion of the second user which is not needed anymore.
132# Added a debug configuration field in /etc/pykota.conf
133# All queries can now be sent to the logger in debug mode, this will
134# greatly help improve performance when time for this will come.
135#
136# Revision 1.12  2003/04/23 22:13:57  jalet
137# Preliminary support for LPRng added BUT STILL UNTESTED.
138#
139# Revision 1.11  2003/04/10 21:47:20  jalet
140# Job history added. Upgrade script neutralized for now !
141#
142# Revision 1.10  2003/03/29 13:45:27  jalet
143# GPL paragraphs were incorrectly (from memory) copied into the sources.
144# Two README files were added.
145# Upgrade script for PostgreSQL pre 1.01 schema was added.
146#
147# Revision 1.9  2003/02/17 22:55:01  jalet
148# More options can now be set per printer or globally :
149#
150#       admin
151#       adminmail
152#       gracedelay
153#       requester
154#
155# the printer option has priority when both are defined.
156#
157# Revision 1.8  2003/02/17 22:05:50  jalet
158# Storage backend now supports admin and user passwords (untested)
159#
160# Revision 1.7  2003/02/10 12:07:31  jalet
161# Now repykota should output the recorded total page number for each printer too.
162#
163# Revision 1.6  2003/02/09 13:05:43  jalet
164# Internationalization continues...
165#
166# Revision 1.5  2003/02/08 22:39:46  jalet
167# --reset command line option added
168#
169# Revision 1.4  2003/02/08 09:59:59  jalet
170# Added preliminary base class for all storages
171#
172# Revision 1.3  2003/02/05 22:10:29  jalet
173# Typos
174#
175# Revision 1.2  2003/02/05 22:02:22  jalet
176# __import__ statement didn't work as expected
177#
178# Revision 1.1  2003/02/05 21:28:17  jalet
179# Initial import into CVS
180#
181#
182#
183
184class PyKotaStorageError(Exception):
185    """An exception for Quota Storage related stuff."""
186    def __init__(self, message = ""):
187        self.message = message
188        Exception.__init__(self, message)
189    def __repr__(self):
190        return self.message
191    __str__ = __repr__
192       
193class StorageObject :
194    """Object present in the Quota Storage."""
195    def __init__(self, parent) :
196        "Initialize minimal data."""
197        self.parent = parent
198        self.ident = None
199        self.Exists = 0
200       
201class StorageUser(StorageObject) :       
202    """User class."""
203    def __init__(self, parent, name) :
204        StorageObject.__init__(self, parent)
205        self.Name = name
206        self.LimitBy = None
207        self.AccountBalance = None
208        self.LifeTimePaid = None
209        self.Email = None
210       
211    def consumeAccountBalance(self, amount) :     
212        """Consumes an amount of money from the user's account balance."""
213        self.parent.decreaseUserAccountBalance(self, amount)
214        self.AccountBalance = float(self.AccountBalance or 0.0) - amount
215       
216    def setAccountBalance(self, balance, lifetimepaid) :   
217        """Sets the user's account balance in case he pays more money."""
218        self.parent.writeUserAccountBalance(self, balance, lifetimepaid)
219        self.AccountBalance = balance
220        self.LifeTimePaid = lifetimepaid
221       
222    def setLimitBy(self, limitby) :   
223        """Sets the user's limiting factor."""
224        try :
225            limitby = limitby.lower()
226        except AttributeError :   
227            limitby = "quota"
228        if limitby in ["quota", "balance"] :
229            self.parent.writeUserLimitBy(self, limitby)
230            self.LimitBy = limitby
231       
232    def delete(self) :   
233        """Deletes an user from the Quota Storage."""
234        self.parent.beginTransaction()
235        try :
236            self.parent.deleteUser(self)
237        except PyKotaStorageError, msg :   
238            self.parent.rollbackTransaction()
239            raise PyKotaStorageError, msg
240        else :   
241            self.parent.commitTransaction()
242       
243class StorageGroup(StorageObject) :       
244    """User class."""
245    def __init__(self, parent, name) :
246        StorageObject.__init__(self, parent)
247        self.Name = name
248        self.LimitBy = None
249        self.AccountBalance = None
250        self.LifeTimePaid = None
251       
252    def setLimitBy(self, limitby) :   
253        """Sets the user's limiting factor."""
254        try :
255            limitby = limitby.lower()
256        except AttributeError :   
257            limitby = "quota"
258        if limitby in ["quota", "balance"] :
259            self.parent.writeGroupLimitBy(self, limitby)
260            self.LimitBy = limitby
261       
262    def delete(self) :   
263        """Deletes a group from the Quota Storage."""
264        self.parent.beginTransaction()
265        try :
266            self.parent.deleteGroup(self)
267        except PyKotaStorageError, msg :   
268            self.parent.rollbackTransaction()
269            raise PyKotaStorageError, msg
270        else :   
271            self.parent.commitTransaction()
272       
273class StoragePrinter(StorageObject) :
274    """Printer class."""
275    def __init__(self, parent, name) :
276        StorageObject.__init__(self, parent)
277        self.Name = name
278        self.PricePerPage = None
279        self.PricePerJob = None
280       
281    def __getattr__(self, name) :   
282        """Delays data retrieval until it's really needed."""
283        if name == "LastJob" : 
284            self.LastJob = self.parent.getPrinterLastJob(self)
285            return self.LastJob
286        else :
287            raise AttributeError, name
288           
289    def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None) :
290        """Adds a job to the printer's history."""
291        self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options)
292        # TODO : update LastJob object ? Probably not needed.
293       
294    def addPrinterToGroup(self, printer) :   
295        """Adds a printer to a printer group."""
296        if (printer not in self.parent.getParentPrinters(self)) and (printer.ident != self.ident) :
297            self.parent.writePrinterToGroup(self, printer)
298            # TODO : reset cached value for printer parents, or add new parent to cached value
299           
300    def delPrinterFromGroup(self, printer) :   
301        """Deletes a printer from a printer group."""
302        self.parent.removePrinterFromGroup(self, printer)
303        # TODO : reset cached value for printer parents, or add new parent to cached value
304       
305    def setPrices(self, priceperpage = None, priceperjob = None) :   
306        """Sets the printer's prices."""
307        if priceperpage is None :
308            priceperpage = self.PricePerPage
309        else :   
310            self.PricePerPage = float(priceperpage)
311        if priceperjob is None :   
312            priceperjob = self.PricePerJob
313        else :   
314            self.PricePerJob = float(priceperjob)
315        self.parent.writePrinterPrices(self)
316       
317    def delete(self) :   
318        """Deletes a printer from the Quota Storage."""
319        self.parent.beginTransaction()
320        try :
321            self.parent.deletePrinter(self)
322        except PyKotaStorageError, msg :   
323            self.parent.rollbackTransaction()
324            raise PyKotaStorageError, msg
325        else :   
326            self.parent.commitTransaction()
327       
328class StorageUserPQuota(StorageObject) :
329    """User Print Quota class."""
330    def __init__(self, parent, user, printer) :
331        StorageObject.__init__(self, parent)
332        self.User = user
333        self.Printer = printer
334        self.PageCounter = None
335        self.LifePageCounter = None
336        self.SoftLimit = None
337        self.HardLimit = None
338        self.DateLimit = None
339       
340    def __getattr__(self, name) :   
341        """Delays data retrieval until it's really needed."""
342        if name == "ParentPrintersUserPQuota" : 
343            self.ParentPrintersUserPQuota = (self.User.Exists and self.Printer.Exists and self.parent.getParentPrintersUserPQuota(self)) or []
344            return self.ParentPrintersUserPQuota
345        else :
346            raise AttributeError, name
347       
348    def setDateLimit(self, datelimit) :   
349        """Sets the date limit for this quota."""
350        date = "%04i-%02i-%02i %02i:%02i:%02i" % (datelimit.year, datelimit.month, datelimit.day, datelimit.hour, datelimit.minute, datelimit.second)
351        self.parent.writeUserPQuotaDateLimit(self, date)
352        self.DateLimit = date
353       
354    def setLimits(self, softlimit, hardlimit) :   
355        """Sets the soft and hard limit for this quota."""
356        self.parent.writeUserPQuotaLimits(self, softlimit, hardlimit)
357        self.SoftLimit = softlimit
358        self.HardLimit = hardlimit
359        self.DateLimit = None
360       
361    def reset(self) :   
362        """Resets page counter to 0."""
363        self.parent.writeUserPQuotaPagesCounters(self, 0, int(self.LifePageCounter or 0))
364        self.PageCounter = 0
365       
366    def computeJobPrice(self, jobsize) :   
367        """Computes the job price as the sum of all parent printers' prices + current printer's ones."""
368        totalprice = 0.0   
369        if jobsize :
370            for upq in [ self ] + self.ParentPrintersUserPQuota :
371                price = (float(upq.Printer.PricePerPage or 0.0) * jobsize) + float(upq.Printer.PricePerJob or 0.0)
372                totalprice += price
373        return totalprice   
374           
375    def increasePagesUsage(self, jobsize) :
376        """Increase the value of used pages and money."""
377        jobprice = self.computeJobPrice(jobsize)
378        if jobsize :
379            self.parent.beginTransaction()
380            try :
381                if jobprice :
382                    self.User.consumeAccountBalance(jobprice)
383                for upq in [ self ] + self.ParentPrintersUserPQuota :
384                    self.parent.increaseUserPQuotaPagesCounters(upq, jobsize)
385                    upq.PageCounter = int(upq.PageCounter or 0) + jobsize
386                    upq.LifePageCounter = int(upq.LifePageCounter or 0) + jobsize
387            except PyKotaStorageError, msg :   
388                self.parent.rollbackTransaction()
389                raise PyKotaStorageError, msg
390            else :   
391                self.parent.commitTransaction()
392        return jobprice
393       
394class StorageGroupPQuota(StorageObject) :
395    """Group Print Quota class."""
396    def __init__(self, parent, group, printer) :
397        StorageObject.__init__(self, parent)
398        self.Group = group
399        self.Printer = printer
400        self.PageCounter = None
401        self.LifePageCounter = None
402        self.SoftLimit = None
403        self.HardLimit = None
404        self.DateLimit = None
405       
406    def __getattr__(self, name) :   
407        """Delays data retrieval until it's really needed."""
408        if name == "ParentPrintersGroupPQuota" : 
409            self.ParentPrintersGroupPQuota = (self.Group.Exists and self.Printer.Exists and self.parent.getParentPrintersGroupPQuota(self)) or []
410            return self.ParentPrintersGroupPQuota
411        else :
412            raise AttributeError, name
413       
414    def setDateLimit(self, datelimit) :   
415        """Sets the date limit for this quota."""
416        date = "%04i-%02i-%02i %02i:%02i:%02i" % (datelimit.year, datelimit.month, datelimit.day, datelimit.hour, datelimit.minute, datelimit.second)
417        self.parent.writeGroupPQuotaDateLimit(self, date)
418        self.DateLimit = date
419       
420    def setLimits(self, softlimit, hardlimit) :   
421        """Sets the soft and hard limit for this quota."""
422        self.parent.writeGroupPQuotaLimits(self, softlimit, hardlimit)
423        self.SoftLimit = softlimit
424        self.HardLimit = hardlimit
425        self.DateLimit = None
426       
427class StorageJob(StorageObject) :
428    """Printer's Last Job class."""
429    def __init__(self, parent) :
430        StorageObject.__init__(self, parent)
431        self.UserName = None
432        self.PrinterName = None
433        self.JobId = None
434        self.PrinterPageCounter = None
435        self.JobSize = None
436        self.JobAction = None
437        self.JobDate = None
438        self.JobPrice = None
439        self.JobFileName = None
440        self.JobTitle = None
441        self.JobCopies = None
442        self.JobOptions = None
443       
444    def __getattr__(self, name) :   
445        """Delays data retrieval until it's really needed."""
446        if name == "User" : 
447            self.User = self.parent.getUser(self.UserName)
448            return self.User
449        elif name == "Printer" :   
450            self.Printer = self.parent.getPrinter(self.PrinterName)
451            return self.Printer
452        else :
453            raise AttributeError, name
454       
455class StorageLastJob(StorageJob) :
456    """Printer's Last Job class."""
457    def __init__(self, parent, printer) :
458        StorageJob.__init__(self, parent)
459        self.PrinterName = printer.Name # not needed
460        self.Printer = printer
461       
462    def __getattr__(self, name) :   
463        """Delays data retrieval until it's really needed."""
464        if name == "User" : 
465            self.User = self.parent.getUser(self.UserName)
466            return self.User
467        else :   
468            raise AttributeError, name
469       
470    def setSize(self, userpquota, jobsize) :
471        """Sets the last job's size."""
472        jobprice = userpquota.computeJobPrice(jobsize)
473        self.parent.writeLastJobSize(self, jobsize, jobprice)
474        self.JobSize = jobsize
475        self.JobPrice = jobprice
476       
477class BaseStorage :
478    def __init__(self, pykotatool) :
479        """Opens the LDAP connection."""
480        # raise PyKotaStorageError, "Sorry, the LDAP backend for PyKota is not yet implemented !"
481        self.closed = 1
482        self.tool = pykotatool
483        self.usecache = pykotatool.config.getCaching()
484        self.disablehistory = pykotatool.config.getDisableHistory()
485        if self.usecache :
486            self.tool.logdebug("Caching enabled.")
487            self.caches = { "USERS" : {}, "GROUPS" : {}, "PRINTERS" : {}, "USERPQUOTAS" : {}, "GROUPPQUOTAS" : {}, "JOBS" : {}, "LASTJOBS" : {} }
488       
489    def close(self) :   
490        """Must be overriden in children classes."""
491        raise RuntimeError, "BaseStorage.close() must be overriden !"
492       
493    def __del__(self) :       
494        """Ensures that the database connection is closed."""
495        self.close()
496       
497    def getFromCache(self, cachetype, key) :
498        """Tries to extract something from the cache."""
499        if self.usecache :
500            entry = self.caches[cachetype].get(key)
501            if entry is not None :
502                self.tool.logdebug("Cache hit (%s->%s)" % (cachetype, key))
503            else :   
504                self.tool.logdebug("Cache miss (%s->%s)" % (cachetype, key))
505            return entry   
506           
507    def cacheEntry(self, cachetype, key, value) :       
508        """Puts an entry in the cache."""
509        if self.usecache and getattr(value, "Exists", 0) :
510            self.caches[cachetype][key] = value
511            self.tool.logdebug("Cache store (%s->%s)" % (cachetype, key))
512           
513    def getUser(self, username) :       
514        """Returns the user from cache."""
515        user = self.getFromCache("USERS", username)
516        if user is None :
517            user = self.getUserFromBackend(username)
518            self.cacheEntry("USERS", username, user)
519        return user   
520       
521    def getGroup(self, groupname) :       
522        """Returns the group from cache."""
523        group = self.getFromCache("GROUPS", groupname)
524        if group is None :
525            group = self.getGroupFromBackend(groupname)
526            self.cacheEntry("GROUPS", groupname, group)
527        return group   
528       
529    def getPrinter(self, printername) :       
530        """Returns the printer from cache."""
531        printer = self.getFromCache("PRINTERS", printername)
532        if printer is None :
533            printer = self.getPrinterFromBackend(printername)
534            self.cacheEntry("PRINTERS", printername, printer)
535        return printer   
536       
537    def getUserPQuota(self, user, printer) :       
538        """Returns the user quota information from cache."""
539        useratprinter = "%s@%s" % (user.Name, printer.Name)
540        upquota = self.getFromCache("USERPQUOTAS", useratprinter)
541        if upquota is None :
542            upquota = self.getUserPQuotaFromBackend(user, printer)
543            self.cacheEntry("USERPQUOTAS", useratprinter, upquota)
544        return upquota   
545       
546    def getGroupPQuota(self, group, printer) :       
547        """Returns the group quota information from cache."""
548        groupatprinter = "%s@%s" % (group.Name, printer.Name)
549        gpquota = self.getFromCache("GROUPPQUOTAS", groupatprinter)
550        if gpquota is None :
551            gpquota = self.getGroupPQuotaFromBackend(group, printer)
552            self.cacheEntry("GROUPPQUOTAS", groupatprinter, gpquota)
553        return gpquota   
554       
555    def getPrinterLastJob(self, printer) :       
556        """Extracts last job information for a given printer from cache."""
557        lastjob = self.getFromCache("LASTJOBS", printer.Name)
558        if lastjob is None :
559            lastjob = self.getPrinterLastJobFromBackend(printer)
560            self.cacheEntry("LASTJOBS", printer.Name, lastjob)
561        return lastjob   
562       
563    def getParentPrinters(self, printer) :   
564        """Extracts parent printers information for a given printer from cache."""
565        if self.usecache :
566            if not hasattr(printer, "Parents") :
567                self.tool.logdebug("Cache miss (%s->Parents)" % printer.Name)
568                printer.Parents = self.getParentPrintersFromBackend(printer)
569                self.tool.logdebug("Cache store (%s->Parents)" % printer.Name)
570            else :
571                self.tool.logdebug("Cache hit (%s->Parents)" % printer.Name)
572        else :       
573            printer.Parents = self.getParentPrintersFromBackend(printer)
574        for parent in printer.Parents[:] :   
575            printer.Parents.extend(self.getParentPrinters(parent))
576        uniquedic = {}   
577        for parent in printer.Parents :
578            uniquedic[parent.Name] = parent
579        printer.Parents = uniquedic.values()   
580        return printer.Parents
581       
582    def getGroupMembers(self, group) :       
583        """Returns the group's members list from in-group cache."""
584        if self.usecache :
585            if not hasattr(group, "Members") :
586                self.tool.logdebug("Cache miss (%s->Members)" % group.Name)
587                group.Members = self.getGroupMembersFromBackend(group)
588                self.tool.logdebug("Cache store (%s->Members)" % group.Name)
589            else :
590                self.tool.logdebug("Cache hit (%s->Members)" % group.Name)
591        else :       
592            group.Members = self.getGroupMembersFromBackend(group)
593        return group.Members   
594       
595    def getUserGroups(self, user) :       
596        """Returns the user's groups list from in-user cache."""
597        if self.usecache :
598            if not hasattr(user, "Groups") :
599                self.tool.logdebug("Cache miss (%s->Groups)" % user.Name)
600                user.Groups = self.getUserGroupsFromBackend(user)
601                self.tool.logdebug("Cache store (%s->Groups)" % user.Name)
602            else :
603                self.tool.logdebug("Cache hit (%s->Groups)" % user.Name)
604        else :       
605            user.Groups = self.getUserGroupsFromBackend(user)
606        return user.Groups   
607       
608    def getParentPrintersUserPQuota(self, userpquota) :     
609        """Returns all user print quota on the printer and all its parents recursively."""
610        upquotas = [ ]
611        for printer in self.getParentPrinters(userpquota.Printer) :
612            upquotas.append(self.getUserPQuota(userpquota.User, printer))
613        return upquotas       
614       
615    def getParentPrintersGroupPQuota(self, grouppquota) :     
616        """Returns all group print quota on the printer and all its parents recursively."""
617        gpquotas = [ ]
618        for printer in self.getParentPrinters(grouppquota.Printer) :
619            gpquotas.append(self.getGroupPQuota(grouppquota.Group, printer))
620        return gpquotas       
621       
622def openConnection(pykotatool) :
623    """Returns a connection handle to the appropriate Quota Storage Database."""
624    backendinfo = pykotatool.config.getStorageBackend()
625    backend = backendinfo["storagebackend"]
626    try :
627        exec "from pykota.storages import %s as storagebackend" % backend.lower()
628    except ImportError :
629        raise PyKotaStorageError, _("Unsupported quota storage backend %s") % backend
630    else :   
631        host = backendinfo["storageserver"]
632        database = backendinfo["storagename"]
633        admin = backendinfo["storageadmin"] or backendinfo["storageuser"]
634        adminpw = backendinfo["storageadminpw"] or backendinfo["storageuserpw"]
635        return storagebackend.Storage(pykotatool, host, database, admin, adminpw)
Note: See TracBrowser for help on using the browser.