git://git.onelab.eu
/
plcapi.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
- use email and smtplib classes to make our e-mails Unicode compatible
[plcapi.git]
/
PLC
/
Keys.py
diff --git
a/PLC/Keys.py
b/PLC/Keys.py
index
841e6eb
..
b81442d
100644
(file)
--- a/
PLC/Keys.py
+++ b/
PLC/Keys.py
@@
-16,13
+16,21
@@
class Key(Row):
table_name = 'keys'
primary_key = 'key_id'
table_name = 'keys'
primary_key = 'key_id'
- join_tables = ['person_key']
+ join_tables = ['person_key'
, 'peer_key'
]
fields = {
'key_id': Parameter(int, "Key identifier"),
'key_type': Parameter(str, "Key type"),
'key': Parameter(str, "Key value", max = 4096),
fields = {
'key_id': Parameter(int, "Key identifier"),
'key_type': Parameter(str, "Key type"),
'key': Parameter(str, "Key value", max = 4096),
+ 'person_id': Parameter(int, "User to which this key belongs", nullok = True),
+ 'peer_id': Parameter(int, "Peer to which this key belongs", nullok = True),
+ 'peer_key_id': Parameter(int, "Foreign key identifier at peer", nullok = True),
}
}
+ # for Cache
+ class_key= 'key'
+ foreign_fields = ['key_type']
+ foreign_xrefs = []
+
def validate_key_type(self, key_type):
key_types = [row['key_type'] for row in KeyTypes(self.api)]
if key_type not in key_types:
def validate_key_type(self, key_type):
key_types = [row['key_type'] for row in KeyTypes(self.api)]
if key_type not in key_types:
@@
-85,7
+93,7
@@
class Key(Row):
" WHERE key_id IN (%s)" % ", ".join(map(str, key_ids)))
# But disassociate them from all join tables
" WHERE key_id IN (%s)" % ", ".join(map(str, key_ids)))
# But disassociate them from all join tables
- for table in
['person_key']
:
+ for table in
self.join_tables
:
self.api.db.do("DELETE FROM %s WHERE key_id IN (%s)" % \
(table, ", ".join(map(str, key_ids))))
self.api.db.do("DELETE FROM %s WHERE key_id IN (%s)" % \
(table, ", ".join(map(str, key_ids))))
@@
-101,7
+109,7
@@
class Keys(Table):
def __init__(self, api, key_filter = None, columns = None):
Table.__init__(self, api, Key, columns)
def __init__(self, api, key_filter = None, columns = None):
Table.__init__(self, api, Key, columns)
- sql = "SELECT %s FROM keys WHERE is_blacklisted IS False" % \
+ sql = "SELECT %s FROM
view_
keys WHERE is_blacklisted IS False" % \
", ".join(self.columns)
if key_filter is not None:
", ".join(self.columns)
if key_filter is not None: