Revision 8397ea8d snf-astakos-app/astakos/quotaholder/callpoint.py
b/snf-astakos-app/astakos/quotaholder/callpoint.py | ||
---|---|---|
56 | 56 |
|
57 | 57 |
api_spec = QuotaholderAPI() |
58 | 58 |
|
59 |
http_exc_lookup = { |
|
60 |
CorruptedError: 550, |
|
61 |
InvalidDataError: 400, |
|
62 |
InvalidKeyError: 401, |
|
63 |
NoEntityError: 404, |
|
64 |
NoQuantityError: 413, |
|
65 |
NoCapacityError: 413, |
|
66 |
} |
|
67 |
|
|
68 | 59 |
def init_connection(self, connection): |
69 | 60 |
if connection is not None: |
70 | 61 |
raise ValueError("Cannot specify connection args with %s" % |
... | ... | |
210 | 201 |
|
211 | 202 |
return holdings |
212 | 203 |
|
213 |
def _set_holding(self, entity, resource, policy, flags): |
|
214 |
try: |
|
215 |
h = db_get_holding(entity=entity, resource=resource, |
|
216 |
for_update=True) |
|
217 |
h.policy = p |
|
218 |
h.flags = flags |
|
219 |
h.save() |
|
220 |
except Holding.DoesNotExist: |
|
221 |
h = Holding.objects.create(entity=e, resource=resource, |
|
222 |
policy=p, flags=flags) |
|
223 |
return h |
|
224 |
|
|
225 | 204 |
def set_holding(self, context=None, set_holding=()): |
226 | 205 |
rejected = [] |
227 | 206 |
append = rejected.append |
... | ... | |
1102 | 1081 |
return x + y if not invert else x - y |
1103 | 1082 |
|
1104 | 1083 |
|
1105 |
def _update(dest, source, attr, delta): |
|
1106 |
dest_attr = getattr(dest, attr) |
|
1107 |
dest_attr = _add(getattr(source, attr, 0), delta) |
|
1108 |
|
|
1109 |
|
|
1110 | 1084 |
def _isneg(x): |
1111 | 1085 |
return x < 0 |
1112 | 1086 |
|
Also available in: Unified diff