Skip to content

Commit d80e9e8

Browse files
author
Ralf Schlatterbeck
committed
Add "lookup" method to xmlrpc interface (Ralf Schlatterbeck)
1 parent 8f98496 commit d80e9e8

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Richard Jones did the change.
77
Features:
88

99
- Add explicit "Search" permissions, see Security Fix below.
10+
- Add "lookup" method to xmlrpc interface (Ralf Schlatterbeck)
1011

1112
Fixed:
1213

doc/xmlrpc.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ set arguments: *designator, arg_1 ... arg_N*
6565
``designator``. The new values are specified in ``arg_1`` through
6666
``arg_N``. The arguments are name=value pairs (e.g. ``status='3'``).
6767

68+
lookup arguments: *classname, key_value*
69+
70+
looks up the key_value for the given class. The class needs to
71+
have a key and the user needs search permission on the key
72+
attribute and id for the given classname.
73+
6874
filter arguments: *classname, list or None, attributes*
6975

7076
list can be None (requires ``allow_none=True`` when
@@ -100,3 +106,5 @@ sample python client
100106
[]
101107
>>> roundup_server.filter('user',[],{'username':'adm'})
102108
[]
109+
>>> roundup_server.lookup('user','admin')
110+
'1'

roundup/xmlrpc.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ def filter(self, classname, search_matches, filterspec,
9999
x = [id for id in result if check('View', uid, classname, itemid=id)]
100100
return x
101101

102+
def lookup(self, classname, key):
103+
cl = self.db.getclass(classname)
104+
uid = self.db.getuid()
105+
prop = cl.getkey()
106+
check = self.db.security.hasSearchPermission
107+
if not check(uid, classname, 'id') or not check(uid, classname, prop):
108+
raise Unauthorised('Permission to search %s denied'%classname)
109+
return cl.lookup(key)
110+
102111
def display(self, designator, *properties):
103112
classname, itemid = hyperdb.splitDesignator(designator)
104113
cl = self.db.getclass(classname)

0 commit comments

Comments
 (0)