author | Pascal Volk <user@localhost.localdomain.org> |
Wed, 27 Jun 2012 12:46:27 +0000 | |
branch | v0.6.x |
changeset 560 | 2662f4e17eb4 |
parent 450 | fd4aa073015f |
child 568 | 14abdd04ddf5 |
permissions | -rw-r--r-- |
385
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
1 |
# -*- coding: UTF-8 -*- |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
2 |
# Copyright (c) 2011, Pascal Volk |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
3 |
# See COPYING for distribution information. |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
4 |
""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
5 |
VirtualMailManager.quotalimit |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
6 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
7 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
8 |
Virtual Mail Manager's QuotaLimit class to manage quota limits |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
9 |
for domains and accounts. |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
10 |
""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
11 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
12 |
from VirtualMailManager.pycompat import all |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
13 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
14 |
_ = lambda msg: msg |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
15 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
16 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
17 |
class QuotaLimit(object): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
18 |
"""Class to handle quota limit specific data.""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
19 |
__slots__ = ('_dbh', '_qid', '_bytes', '_messages') |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
20 |
_kwargs = ('qid', 'bytes', 'messages') |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
21 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
22 |
def __init__(self, dbh, **kwargs): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
23 |
"""Create a new QuotaLimit instance. |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
24 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
25 |
Either the `qid` keyword or the `bytes` and `messages` keywords |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
26 |
must be specified. |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
27 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
28 |
Arguments: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
29 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
30 |
`dbh` : pyPgSQL.PgSQL.Connection || psycopg2._psycopg.connection |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
31 |
A database connection for the database access. |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
32 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
33 |
Keyword arguments: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
34 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
35 |
`qid` : int |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
36 |
The id of a quota limit |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
37 |
`bytes` : long |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
38 |
The quota limit in bytes. |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
39 |
`messages` : int |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
40 |
The quota limit in number of messages |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
41 |
""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
42 |
self._dbh = dbh |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
43 |
self._qid = 0 |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
44 |
self._bytes = 0 |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
45 |
self._messages = 0 |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
46 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
47 |
for key in kwargs.iterkeys(): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
48 |
if key not in self.__class__._kwargs: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
49 |
raise ValueError('unrecognized keyword: %r' % key) |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
50 |
qid = kwargs.get('qid') |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
51 |
if qid is not None: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
52 |
assert isinstance(qid, (int, long)) |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
53 |
self._load_by_qid(qid) |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
54 |
else: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
55 |
bytes_, msgs = kwargs.get('bytes'), kwargs.get('messages') |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
56 |
assert all(isinstance(i, (int, long)) for i in (bytes_, msgs)) |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
57 |
if bytes_ < 0: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
58 |
self._bytes = -bytes_ |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
59 |
else: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
60 |
self._bytes = bytes_ |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
61 |
if msgs < 0: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
62 |
self._messages = -msgs |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
63 |
else: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
64 |
self._messages = msgs |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
65 |
self._load_by_limit() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
66 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
67 |
@property |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
68 |
def bytes(self): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
69 |
"""Quota limit in bytes.""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
70 |
return self._bytes |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
71 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
72 |
@property |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
73 |
def messages(self): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
74 |
"""Quota limit in number of messages.""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
75 |
return self._messages |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
76 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
77 |
@property |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
78 |
def qid(self): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
79 |
"""The quota limit's unique ID.""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
80 |
return self._qid |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
81 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
82 |
def __eq__(self, other): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
83 |
if isinstance(other, self.__class__): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
84 |
return self._qid == other._qid |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
85 |
return NotImplemented |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
86 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
87 |
def __ne__(self, other): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
88 |
if isinstance(other, self.__class__): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
89 |
return self._qid != other._qid |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
90 |
return NotImplemented |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
91 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
92 |
def _load_by_limit(self): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
93 |
"""Load the quota limit by limit values from the database.""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
94 |
dbc = self._dbh.cursor() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
95 |
dbc.execute('SELECT qid FROM quotalimit WHERE bytes = %s AND ' |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
96 |
'messages = %s', (self._bytes, self._messages)) |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
97 |
res = dbc.fetchone() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
98 |
dbc.close() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
99 |
if res: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
100 |
self._qid = res[0] |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
101 |
else: |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
102 |
self._save() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
103 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
104 |
def _load_by_qid(self, qid): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
105 |
"""Load the quota limit by its unique ID from the database.""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
106 |
dbc = self._dbh.cursor() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
107 |
dbc.execute('SELECT bytes, messages FROM quotalimit WHERE qid = %s', |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
108 |
(qid,)) |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
109 |
res = dbc.fetchone() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
110 |
dbc.close() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
111 |
if not res: |
450
fd4aa073015f
VMM/{maillocation,quotalimit}: Unified object initialization code.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
407
diff
changeset
|
112 |
raise ValueError('Unknown quota limit id specified: %r' % qid) |
385
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
113 |
self._qid = qid |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
114 |
self._bytes, self._messages = res |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
115 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
116 |
def _save(self): |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
117 |
"""Store a new quota limit in the database.""" |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
118 |
dbc = self._dbh.cursor() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
119 |
dbc.execute("SELECT nextval('quotalimit_id')") |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
120 |
self._qid = dbc.fetchone()[0] |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
121 |
dbc.execute('INSERT INTO quotalimit (qid, bytes, messages) VALUES ' |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
122 |
'(%s, %s, %s)', (self._qid, self._bytes, self._messages)) |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
123 |
self._dbh.commit() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
124 |
dbc.close() |
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
125 |
|
0cae9989395b
VMM/quotalimit: Added new module quotalimit to the repository.
Pascal Volk <neverseen@users.sourceforge.net>
parents:
diff
changeset
|
126 |
del _ |