Mercurial > p > roundup > code
comparison roundup/xmlrpc.py @ 4140:3c4545f55949
Allow XMLRPC clients to fetch tracker schema.
| author | Stefan Seefeld <stefan@seefeld.name> |
|---|---|
| date | Fri, 19 Jun 2009 17:10:07 +0000 |
| parents | 0ad79301f055 |
| children | 3f6cadb98c2f |
comparison
equal
deleted
inserted
replaced
| 4136:c5c08eefdf23 | 4140:3c4545f55949 |
|---|---|
| 57 | 57 |
| 58 self.db = db | 58 self.db = db |
| 59 self.actions = actions | 59 self.actions = actions |
| 60 self.translator = translator | 60 self.translator = translator |
| 61 | 61 |
| 62 def schema(self): | |
| 63 s = {} | |
| 64 for c in self.db.classes: | |
| 65 cls = self.db.classes[c] | |
| 66 props = [(n,repr(v)) for n,v in cls.properties.items()] | |
| 67 s[c] = props | |
| 68 return s | |
| 69 | |
| 62 def list(self, classname, propname=None): | 70 def list(self, classname, propname=None): |
| 63 cl = self.db.getclass(classname) | 71 cl = self.db.getclass(classname) |
| 64 if not propname: | 72 if not propname: |
| 65 propname = cl.labelprop() | 73 propname = cl.labelprop() |
| 66 result = [cl.get(itemid, propname) | 74 result = [cl.get(itemid, propname) |
| 105 raise UsageError, 'you must provide the "%s" property.'%key | 113 raise UsageError, 'you must provide the "%s" property.'%key |
| 106 | 114 |
| 107 for key in props: | 115 for key in props: |
| 108 if not self.db.security.hasPermission('Edit', self.db.getuid(), classname, | 116 if not self.db.security.hasPermission('Edit', self.db.getuid(), classname, |
| 109 property=key): | 117 property=key): |
| 110 raise Unauthorised('Permission to create %s denied'%classname) | 118 raise Unauthorised('Permission to set %s.%s denied'%(classname, key)) |
| 111 | 119 |
| 112 # do the actual create | 120 # do the actual create |
| 113 try: | 121 try: |
| 114 result = cl.create(**props) | 122 result = cl.create(**props) |
| 115 except (TypeError, IndexError, ValueError), message: | 123 except (TypeError, IndexError, ValueError), message: |
