Revision 7efc9f86
b/snf-pithos-app/pithos/api/functions.py | ||
---|---|---|
54 | 54 |
SaveToBackendHandler, object_data_response, put_object_block, hashmap_md5, simple_list_response, api_method) |
55 | 55 |
from pithos.api.settings import UPDATE_MD5 |
56 | 56 |
|
57 |
from pithos.backends.base import NotAllowedError, QuotaError |
|
57 |
from pithos.backends.base import NotAllowedError, QuotaError, ContainerNotEmpty, ItemNotExists, VersionNotExists |
|
58 |
|
|
58 | 59 |
from pithos.backends.filter import parse_filters |
59 | 60 |
|
60 | 61 |
import logging |
... | ... | |
330 | 331 |
v_container) |
331 | 332 |
except NotAllowedError: |
332 | 333 |
raise Forbidden('Not allowed') |
333 |
except NameError:
|
|
334 |
except ItemNotExists:
|
|
334 | 335 |
raise ItemNotFound('Container does not exist') |
335 | 336 |
|
336 | 337 |
validate_modification_preconditions(request, meta) |
... | ... | |
365 | 366 |
v_container, policy, replace=False) |
366 | 367 |
except NotAllowedError: |
367 | 368 |
raise Forbidden('Not allowed') |
368 |
except NameError:
|
|
369 |
except ItemNotExists:
|
|
369 | 370 |
raise ItemNotFound('Container does not exist') |
370 | 371 |
except ValueError: |
371 | 372 |
raise BadRequest('Invalid policy header') |
... | ... | |
375 | 376 |
v_container, 'pithos', meta, replace=False) |
376 | 377 |
except NotAllowedError: |
377 | 378 |
raise Forbidden('Not allowed') |
378 |
except NameError:
|
|
379 |
except ItemNotExists:
|
|
379 | 380 |
raise ItemNotFound('Container does not exist') |
380 | 381 |
|
381 | 382 |
return HttpResponse(status=ret) |
... | ... | |
398 | 399 |
v_container, policy, replace) |
399 | 400 |
except NotAllowedError: |
400 | 401 |
raise Forbidden('Not allowed') |
401 |
except NameError:
|
|
402 |
except ItemNotExists:
|
|
402 | 403 |
raise ItemNotFound('Container does not exist') |
403 | 404 |
except ValueError: |
404 | 405 |
raise BadRequest('Invalid policy header') |
... | ... | |
408 | 409 |
v_container, 'pithos', meta, replace) |
409 | 410 |
except NotAllowedError: |
410 | 411 |
raise Forbidden('Not allowed') |
411 |
except NameError:
|
|
412 |
except ItemNotExists:
|
|
412 | 413 |
raise ItemNotFound('Container does not exist') |
413 | 414 |
|
414 | 415 |
content_length = -1 |
... | ... | |
443 | 444 |
until) |
444 | 445 |
except NotAllowedError: |
445 | 446 |
raise Forbidden('Not allowed') |
446 |
except NameError:
|
|
447 |
except ItemNotExists:
|
|
447 | 448 |
raise ItemNotFound('Container does not exist') |
448 |
except IndexError:
|
|
449 |
except ContainerNotEmpty:
|
|
449 | 450 |
raise Conflict('Container is not empty') |
450 | 451 |
return HttpResponse(status=204) |
451 | 452 |
|
... | ... | |
467 | 468 |
v_container) |
468 | 469 |
except NotAllowedError: |
469 | 470 |
raise Forbidden('Not allowed') |
470 |
except NameError:
|
|
471 |
except ItemNotExists:
|
|
471 | 472 |
raise ItemNotFound('Container does not exist') |
472 | 473 |
|
473 | 474 |
validate_modification_preconditions(request, meta) |
... | ... | |
524 | 525 |
until, None, public) |
525 | 526 |
except NotAllowedError: |
526 | 527 |
raise Forbidden('Not allowed') |
527 |
except NameError:
|
|
528 |
except ItemNotExists:
|
|
528 | 529 |
raise ItemNotFound('Container does not exist') |
529 | 530 |
|
530 | 531 |
if len(objects) == 0: |
... | ... | |
553 | 554 |
object_public[k[name_idx:]] = v |
554 | 555 |
except NotAllowedError: |
555 | 556 |
raise Forbidden('Not allowed') |
556 |
except NameError:
|
|
557 |
except ItemNotExists:
|
|
557 | 558 |
raise ItemNotFound('Container does not exist') |
558 | 559 |
|
559 | 560 |
object_meta = [] |
... | ... | |
610 | 611 |
public = None |
611 | 612 |
except NotAllowedError: |
612 | 613 |
raise Forbidden('Not allowed') |
613 |
except NameError:
|
|
614 |
except ItemNotExists:
|
|
614 | 615 |
raise ItemNotFound('Object does not exist') |
615 |
except IndexError:
|
|
616 |
except VersionNotExists:
|
|
616 | 617 |
raise ItemNotFound('Version does not exist') |
617 | 618 |
|
618 | 619 |
update_manifest_meta(request, v_account, meta) |
... | ... | |
679 | 680 |
public = None |
680 | 681 |
except NotAllowedError: |
681 | 682 |
raise Forbidden('Not allowed') |
682 |
except NameError:
|
|
683 |
except ItemNotExists:
|
|
683 | 684 |
raise ItemNotFound('Object does not exist') |
684 |
except IndexError:
|
|
685 |
except VersionNotExists:
|
|
685 | 686 |
raise ItemNotFound('Version does not exist') |
686 | 687 |
|
687 | 688 |
update_manifest_meta(request, v_account, meta) |
... | ... | |
712 | 713 |
raise Forbidden('Not allowed') |
713 | 714 |
except ValueError: |
714 | 715 |
raise BadRequest('Invalid X-Object-Manifest header') |
715 |
except NameError:
|
|
716 |
except ItemNotExists:
|
|
716 | 717 |
raise ItemNotFound('Container does not exist') |
717 | 718 |
|
718 | 719 |
try: |
... | ... | |
723 | 724 |
hashmaps.append(h) |
724 | 725 |
except NotAllowedError: |
725 | 726 |
raise Forbidden('Not allowed') |
726 |
except NameError:
|
|
727 |
except ItemNotExists:
|
|
727 | 728 |
raise ItemNotFound('Object does not exist') |
728 |
except IndexError:
|
|
729 |
except VersionNotExists:
|
|
729 | 730 |
raise ItemNotFound('Version does not exist') |
730 | 731 |
else: |
731 | 732 |
try: |
... | ... | |
735 | 736 |
hashmaps.append(h) |
736 | 737 |
except NotAllowedError: |
737 | 738 |
raise Forbidden('Not allowed') |
738 |
except NameError:
|
|
739 |
except ItemNotExists:
|
|
739 | 740 |
raise ItemNotFound('Object does not exist') |
740 |
except IndexError:
|
|
741 |
except VersionNotExists:
|
|
741 | 742 |
raise ItemNotFound('Version does not exist') |
742 | 743 |
|
743 | 744 |
# Reply with the hashmap. |
... | ... | |
877 | 878 |
raise Forbidden('Not allowed') |
878 | 879 |
except IndexError, e: |
879 | 880 |
raise Conflict(simple_list_response(request, e.data)) |
880 |
except NameError:
|
|
881 |
except ItemNotExists:
|
|
881 | 882 |
raise ItemNotFound('Container does not exist') |
882 | 883 |
except ValueError: |
883 | 884 |
raise BadRequest('Invalid sharing header') |
... | ... | |
897 | 898 |
v_container, v_object, public) |
898 | 899 |
except NotAllowedError: |
899 | 900 |
raise Forbidden('Not allowed') |
900 |
except NameError:
|
|
901 |
except ItemNotExists:
|
|
901 | 902 |
raise ItemNotFound('Object does not exist') |
902 | 903 |
|
903 | 904 |
response = HttpResponse(status=201) |
... | ... | |
926 | 927 |
file.hashmap, checksum, 'pithos', {}, True) |
927 | 928 |
except NotAllowedError: |
928 | 929 |
raise Forbidden('Not allowed') |
929 |
except NameError:
|
|
930 |
except ItemNotExists:
|
|
930 | 931 |
raise ItemNotFound('Container does not exist') |
931 | 932 |
except QuotaError: |
932 | 933 |
raise RequestEntityTooLarge('Quota exceeded') |
... | ... | |
964 | 965 |
v_container, v_object, 'pithos', src_version) |
965 | 966 |
except NotAllowedError: |
966 | 967 |
raise Forbidden('Not allowed') |
967 |
except (NameError, IndexError):
|
|
968 |
except (ItemNotExists, VersionNotExists):
|
|
968 | 969 |
raise ItemNotFound('Container or object does not exist') |
969 | 970 |
validate_matching_preconditions(request, meta) |
970 | 971 |
|
... | ... | |
1002 | 1003 |
v_container, v_object, 'pithos') |
1003 | 1004 |
except NotAllowedError: |
1004 | 1005 |
raise Forbidden('Not allowed') |
1005 |
except NameError:
|
|
1006 |
except ItemNotExists:
|
|
1006 | 1007 |
raise ItemNotFound('Container or object does not exist') |
1007 | 1008 |
validate_matching_preconditions(request, meta) |
1008 | 1009 |
|
... | ... | |
1030 | 1031 |
v_container, v_object, 'pithos') |
1031 | 1032 |
except NotAllowedError: |
1032 | 1033 |
raise Forbidden('Not allowed') |
1033 |
except NameError:
|
|
1034 |
except ItemNotExists:
|
|
1034 | 1035 |
raise ItemNotFound('Object does not exist') |
1035 | 1036 |
|
1036 | 1037 |
# Evaluate conditions. |
... | ... | |
1053 | 1054 |
v_account, v_container, v_object, permissions) |
1054 | 1055 |
except NotAllowedError: |
1055 | 1056 |
raise Forbidden('Not allowed') |
1056 |
except NameError:
|
|
1057 |
except ItemNotExists:
|
|
1057 | 1058 |
raise ItemNotFound('Object does not exist') |
1058 | 1059 |
except ValueError: |
1059 | 1060 |
raise BadRequest('Invalid sharing header') |
... | ... | |
1063 | 1064 |
v_container, v_object, public) |
1064 | 1065 |
except NotAllowedError: |
1065 | 1066 |
raise Forbidden('Not allowed') |
1066 |
except NameError:
|
|
1067 |
except ItemNotExists:
|
|
1067 | 1068 |
raise ItemNotFound('Object does not exist') |
1068 | 1069 |
if meta or replace: |
1069 | 1070 |
try: |
... | ... | |
1071 | 1072 |
v_account, v_container, v_object, 'pithos', meta, replace) |
1072 | 1073 |
except NotAllowedError: |
1073 | 1074 |
raise Forbidden('Not allowed') |
1074 |
except NameError:
|
|
1075 |
except ItemNotExists:
|
|
1075 | 1076 |
raise ItemNotFound('Object does not exist') |
1076 | 1077 |
response['X-Object-Version'] = version_id |
1077 | 1078 |
|
... | ... | |
1092 | 1093 |
v_account, v_container, v_object) |
1093 | 1094 |
except NotAllowedError: |
1094 | 1095 |
raise Forbidden('Not allowed') |
1095 |
except NameError:
|
|
1096 |
except ItemNotExists:
|
|
1096 | 1097 |
raise ItemNotFound('Object does not exist') |
1097 | 1098 |
|
1098 | 1099 |
offset, length, total = ranges |
... | ... | |
1111 | 1112 |
src_account, src_container, src_name, src_version) |
1112 | 1113 |
except NotAllowedError: |
1113 | 1114 |
raise Forbidden('Not allowed') |
1114 |
except NameError:
|
|
1115 |
except ItemNotExists:
|
|
1115 | 1116 |
raise ItemNotFound('Source object does not exist') |
1116 | 1117 |
|
1117 | 1118 |
if length is None: |
... | ... | |
1197 | 1198 |
hashmap, checksum, 'pithos', meta, replace, permissions) |
1198 | 1199 |
except NotAllowedError: |
1199 | 1200 |
raise Forbidden('Not allowed') |
1200 |
except NameError:
|
|
1201 |
except ItemNotExists:
|
|
1201 | 1202 |
raise ItemNotFound('Container does not exist') |
1202 | 1203 |
except ValueError: |
1203 | 1204 |
raise BadRequest('Invalid sharing header') |
... | ... | |
1209 | 1210 |
v_container, v_object, public) |
1210 | 1211 |
except NotAllowedError: |
1211 | 1212 |
raise Forbidden('Not allowed') |
1212 |
except NameError:
|
|
1213 |
except ItemNotExists:
|
|
1213 | 1214 |
raise ItemNotFound('Object does not exist') |
1214 | 1215 |
|
1215 | 1216 |
response = HttpResponse(status=204) |
... | ... | |
1233 | 1234 |
v_object, until, delimiter=delimiter) |
1234 | 1235 |
except NotAllowedError: |
1235 | 1236 |
raise Forbidden('Not allowed') |
1236 |
except NameError:
|
|
1237 |
except ItemNotExists:
|
|
1237 | 1238 |
raise ItemNotFound('Object does not exist') |
1238 | 1239 |
return HttpResponse(status=204) |
1239 | 1240 |
|
b/snf-pithos-app/pithos/api/util.py | ||
---|---|---|
64 | 64 |
SERVICE_TOKEN, COOKIE_NAME) |
65 | 65 |
|
66 | 66 |
from pithos.backends import connect_backend |
67 |
from pithos.backends.base import NotAllowedError, QuotaError |
|
67 |
from pithos.backends.base import NotAllowedError, QuotaError, ItemNotExists, VersionNotExists
|
|
68 | 68 |
|
69 | 69 |
import logging |
70 | 70 |
import re |
... | ... | |
340 | 340 |
content_type, 'pithos', meta, False, permissions, src_version, delimiter) |
341 | 341 |
except NotAllowedError: |
342 | 342 |
raise Forbidden('Not allowed') |
343 |
except (NameError, IndexError):
|
|
343 |
except (ItemNotExists, VersionNotExists):
|
|
344 | 344 |
raise ItemNotFound('Container or object does not exist') |
345 | 345 |
except ValueError: |
346 | 346 |
raise BadRequest('Invalid sharing header') |
... | ... | |
351 | 351 |
request.backend.update_object_public(request.user_uniq, dest_account, dest_container, dest_name, public) |
352 | 352 |
except NotAllowedError: |
353 | 353 |
raise Forbidden('Not allowed') |
354 |
except NameError:
|
|
354 |
except ItemNotExists:
|
|
355 | 355 |
raise ItemNotFound('Object does not exist') |
356 | 356 |
return version_id |
357 | 357 |
|
... | ... | |
662 | 662 |
self.block_hash = self.hashmaps[self.file_index][self.block_index] |
663 | 663 |
try: |
664 | 664 |
self.block = self.backend.get_block(self.block_hash) |
665 |
except NameError:
|
|
665 |
except ItemNotExists:
|
|
666 | 666 |
raise ItemNotFound('Block does not exist') |
667 | 667 |
|
668 | 668 |
# Get the data from the block. |
b/snf-pithos-backend/pithos/backends/base.py | ||
---|---|---|
42 | 42 |
class QuotaError(Exception): |
43 | 43 |
pass |
44 | 44 |
|
45 |
class AccountExists(NameError): |
|
46 |
pass |
|
47 |
|
|
48 |
class ContainerExists(NameError): |
|
49 |
pass |
|
50 |
|
|
51 |
class AccountNotEmpty(IndexError): |
|
52 |
pass |
|
53 |
|
|
54 |
class ContainerNotEmpty(IndexError): |
|
55 |
pass |
|
56 |
|
|
57 |
class ItemNotExists(NameError): |
|
58 |
pass |
|
59 |
|
|
60 |
class VersionNotExists(IndexError): |
|
61 |
pass |
|
62 |
|
|
45 | 63 |
class BaseBackend(object): |
46 | 64 |
"""Abstract backend class that serves as a reference for actual implementations. |
47 | 65 |
|
... | ... | |
165 | 183 |
Raises: |
166 | 184 |
NotAllowedError: Operation not permitted |
167 | 185 |
|
168 |
IndexError: Account is not empty
|
|
186 |
AccountNotEmpty: Account is not empty
|
|
169 | 187 |
""" |
170 | 188 |
return |
171 | 189 |
|
... | ... | |
193 | 211 |
Raises: |
194 | 212 |
NotAllowedError: Operation not permitted |
195 | 213 |
|
196 |
NameError: Container does not exist
|
|
214 |
ItemNotExists: Container does not exist
|
|
197 | 215 |
""" |
198 | 216 |
return [] |
199 | 217 |
|
... | ... | |
214 | 232 |
Raises: |
215 | 233 |
NotAllowedError: Operation not permitted |
216 | 234 |
|
217 |
NameError: Container does not exist
|
|
235 |
ItemNotExists: Container does not exist
|
|
218 | 236 |
""" |
219 | 237 |
return {} |
220 | 238 |
|
... | ... | |
231 | 249 |
Raises: |
232 | 250 |
NotAllowedError: Operation not permitted |
233 | 251 |
|
234 |
NameError: Container does not exist
|
|
252 |
ItemNotExists: Container does not exist
|
|
235 | 253 |
""" |
236 | 254 |
return |
237 | 255 |
|
... | ... | |
246 | 264 |
Raises: |
247 | 265 |
NotAllowedError: Operation not permitted |
248 | 266 |
|
249 |
NameError: Container does not exist
|
|
267 |
ItemNotExists: Container does not exist
|
|
250 | 268 |
""" |
251 | 269 |
return {} |
252 | 270 |
|
... | ... | |
256 | 274 |
Raises: |
257 | 275 |
NotAllowedError: Operation not permitted |
258 | 276 |
|
259 |
NameError: Container does not exist
|
|
277 |
ItemNotExists: Container does not exist
|
|
260 | 278 |
|
261 | 279 |
ValueError: Invalid policy defined |
262 | 280 |
""" |
... | ... | |
268 | 286 |
Raises: |
269 | 287 |
NotAllowedError: Operation not permitted |
270 | 288 |
|
271 |
NameError: Container already exists
|
|
289 |
ContainerExists: Container already exists
|
|
272 | 290 |
|
273 | 291 |
ValueError: Invalid policy defined |
274 | 292 |
""" |
... | ... | |
280 | 298 |
Raises: |
281 | 299 |
NotAllowedError: Operation not permitted |
282 | 300 |
|
283 |
NameError: Container does not exist
|
|
301 |
ItemNotExists: Container does not exist
|
|
284 | 302 |
|
285 |
IndexError: Container is not empty
|
|
303 |
ContainerNotEmpty: Container is not empty
|
|
286 | 304 |
""" |
287 | 305 |
return |
288 | 306 |
|
... | ... | |
321 | 339 |
Raises: |
322 | 340 |
NotAllowedError: Operation not permitted |
323 | 341 |
|
324 |
NameError: Container does not exist
|
|
342 |
ItemNotExists: Container does not exist
|
|
325 | 343 |
""" |
326 | 344 |
return [] |
327 | 345 |
|
... | ... | |
334 | 352 |
Raises: |
335 | 353 |
NotAllowedError: Operation not permitted |
336 | 354 |
|
337 |
NameError: Container does not exist
|
|
355 |
ItemNotExists: Container does not exist
|
|
338 | 356 |
""" |
339 | 357 |
return [] |
340 | 358 |
|
... | ... | |
377 | 395 |
Raises: |
378 | 396 |
NotAllowedError: Operation not permitted |
379 | 397 |
|
380 |
NameError: Container/object does not exist
|
|
398 |
ItemNotExists: Container/object does not exist
|
|
381 | 399 |
|
382 |
IndexError: Version does not exist
|
|
400 |
VersionNotExists: Version does not exist
|
|
383 | 401 |
""" |
384 | 402 |
return {} |
385 | 403 |
|
... | ... | |
396 | 414 |
Raises: |
397 | 415 |
NotAllowedError: Operation not permitted |
398 | 416 |
|
399 |
NameError: Container/object does not exist
|
|
417 |
ItemNotExists: Container/object does not exist
|
|
400 | 418 |
""" |
401 | 419 |
return '' |
402 | 420 |
|
... | ... | |
413 | 431 |
Raises: |
414 | 432 |
NotAllowedError: Operation not permitted |
415 | 433 |
|
416 |
NameError: Container/object does not exist
|
|
434 |
ItemNotExists: Container/object does not exist
|
|
417 | 435 |
""" |
418 | 436 |
return {} |
419 | 437 |
|
... | ... | |
426 | 444 |
Raises: |
427 | 445 |
NotAllowedError: Operation not permitted |
428 | 446 |
|
429 |
NameError: Container/object does not exist
|
|
447 |
ItemNotExists: Container/object does not exist
|
|
430 | 448 |
|
431 | 449 |
ValueError: Invalid users/groups in permissions |
432 | 450 |
""" |
... | ... | |
438 | 456 |
Raises: |
439 | 457 |
NotAllowedError: Operation not permitted |
440 | 458 |
|
441 |
NameError: Container/object does not exist
|
|
459 |
ItemNotExists: Container/object does not exist
|
|
442 | 460 |
""" |
443 | 461 |
return None |
444 | 462 |
|
... | ... | |
451 | 469 |
Raises: |
452 | 470 |
NotAllowedError: Operation not permitted |
453 | 471 |
|
454 |
NameError: Container/object does not exist
|
|
472 |
ItemNotExists: Container/object does not exist
|
|
455 | 473 |
""" |
456 | 474 |
return |
457 | 475 |
|
... | ... | |
461 | 479 |
Raises: |
462 | 480 |
NotAllowedError: Operation not permitted |
463 | 481 |
|
464 |
NameError: Container/object does not exist
|
|
482 |
ItemNotExists: Container/object does not exist
|
|
465 | 483 |
|
466 |
IndexError: Version does not exist
|
|
484 |
VersionNotExists: Version does not exist
|
|
467 | 485 |
""" |
468 | 486 |
return 0, [] |
469 | 487 |
|
... | ... | |
482 | 500 |
Raises: |
483 | 501 |
NotAllowedError: Operation not permitted |
484 | 502 |
|
485 |
NameError: Container does not exist
|
|
503 |
ItemNotExists: Container does not exist
|
|
486 | 504 |
|
487 | 505 |
ValueError: Invalid users/groups in permissions |
488 | 506 |
|
... | ... | |
513 | 531 |
Raises: |
514 | 532 |
NotAllowedError: Operation not permitted |
515 | 533 |
|
516 |
NameError: Container/object does not exist
|
|
534 |
ItemNotExists: Container/object does not exist
|
|
517 | 535 |
|
518 |
IndexError: Version does not exist
|
|
536 |
VersionNotExists: Version does not exist
|
|
519 | 537 |
|
520 | 538 |
ValueError: Invalid users/groups in permissions |
521 | 539 |
|
... | ... | |
540 | 558 |
Raises: |
541 | 559 |
NotAllowedError: Operation not permitted |
542 | 560 |
|
543 |
NameError: Container/object does not exist
|
|
561 |
ItemNotExists: Container/object does not exist
|
|
544 | 562 |
|
545 | 563 |
ValueError: Invalid users/groups in permissions |
546 | 564 |
|
... | ... | |
557 | 575 |
Raises: |
558 | 576 |
NotAllowedError: Operation not permitted |
559 | 577 |
|
560 |
NameError: Container/object does not exist
|
|
578 |
ItemNotExists: Container/object does not exist
|
|
561 | 579 |
""" |
562 | 580 |
return |
563 | 581 |
|
... | ... | |
593 | 611 |
"""Return a block's data. |
594 | 612 |
|
595 | 613 |
Raises: |
596 |
NameError: Block does not exist
|
|
614 |
ItemNotExists: Block does not exist
|
|
597 | 615 |
""" |
598 | 616 |
return '' |
599 | 617 |
|
b/snf-pithos-backend/pithos/backends/modular.py | ||
---|---|---|
39 | 39 |
import hashlib |
40 | 40 |
import binascii |
41 | 41 |
|
42 |
from base import DEFAULT_QUOTA, DEFAULT_VERSIONING, NotAllowedError, QuotaError, BaseBackend |
|
42 |
from base import DEFAULT_QUOTA, DEFAULT_VERSIONING, NotAllowedError, QuotaError, BaseBackend, \ |
|
43 |
AccountExists, ContainerExists, AccountNotEmpty, ContainerNotEmpty, ItemNotExists, VersionNotExists |
|
43 | 44 |
|
44 | 45 |
# Stripped-down version of the HashMap class found in tools. |
45 | 46 |
class HashMap(list): |
... | ... | |
292 | 293 |
raise NotAllowedError |
293 | 294 |
node = self.node.node_lookup(account) |
294 | 295 |
if node is not None: |
295 |
raise NameError('Account already exists')
|
|
296 |
raise AccountExists('Account already exists')
|
|
296 | 297 |
if policy: |
297 | 298 |
self._check_policy(policy) |
298 | 299 |
node = self._put_path(user, self.ROOTNODE, account) |
... | ... | |
309 | 310 |
if node is None: |
310 | 311 |
return |
311 | 312 |
if not self.node.node_remove(node): |
312 |
raise IndexError('Account is not empty')
|
|
313 |
raise AccountNotEmpty('Account is not empty')
|
|
313 | 314 |
self.permissions.group_destroy(account) |
314 | 315 |
|
315 | 316 |
@backend_method |
... | ... | |
434 | 435 |
except NameError: |
435 | 436 |
pass |
436 | 437 |
else: |
437 |
raise NameError('Container already exists')
|
|
438 |
raise ContainerExists('Container already exists')
|
|
438 | 439 |
if policy: |
439 | 440 |
self._check_policy(policy) |
440 | 441 |
path = '/'.join((account, container)) |
... | ... | |
459 | 460 |
return |
460 | 461 |
|
461 | 462 |
if self._get_statistics(node)[0] > 0: |
462 |
raise IndexError('Container is not empty')
|
|
463 |
raise ContainerNotEmpty('Container is not empty')
|
|
463 | 464 |
hashes, size = self.node.node_purge_children(node, inf, CLUSTER_HISTORY) |
464 | 465 |
for h in hashes: |
465 | 466 |
self.store.map_delete(h) |
... | ... | |
601 | 602 |
except NameError: # Object may be deleted. |
602 | 603 |
del_props = self.node.version_lookup(node, inf, CLUSTER_DELETED) |
603 | 604 |
if del_props is None: |
604 |
raise NameError('Object does not exist')
|
|
605 |
raise ItemNotExists('Object does not exist')
|
|
605 | 606 |
modified = del_props[self.MTIME] |
606 | 607 |
|
607 | 608 |
meta = {} |
... | ... | |
919 | 920 |
logger.debug("get_block: %s", hash) |
920 | 921 |
block = self.store.block_get(binascii.unhexlify(hash)) |
921 | 922 |
if not block: |
922 |
raise NameError('Block does not exist')
|
|
923 |
raise ItemNotExists('Block does not exist')
|
|
923 | 924 |
return block |
924 | 925 |
|
925 | 926 |
@backend_method(autocommit=0) |
... | ... | |
966 | 967 |
path = '/'.join((account, container)) |
967 | 968 |
node = self.node.node_lookup(path) |
968 | 969 |
if node is None: |
969 |
raise NameError('Container does not exist')
|
|
970 |
raise ItemNotExists('Container does not exist')
|
|
970 | 971 |
return path, node |
971 | 972 |
|
972 | 973 |
def _lookup_object(self, account, container, name): |
973 | 974 |
path = '/'.join((account, container, name)) |
974 | 975 |
node = self.node.node_lookup(path) |
975 | 976 |
if node is None: |
976 |
raise NameError('Object does not exist')
|
|
977 |
raise ItemNotExists('Object does not exist')
|
|
977 | 978 |
return path, node |
978 | 979 |
|
979 | 980 |
def _lookup_objects(self, paths): |
980 |
nodes = self.node.node_lookup_bulk(paths) |
|
981 |
if nodes is None: |
|
982 |
raise NameError('Object does not exist') |
|
981 |
nodes = self.node.node_lookup_bulk(paths) |
|
983 | 982 |
return paths, nodes |
984 | 983 |
|
985 | 984 |
def _get_properties(self, node, until=None): |
... | ... | |
990 | 989 |
if props is None and until is not None: |
991 | 990 |
props = self.node.version_lookup(node, before, CLUSTER_HISTORY) |
992 | 991 |
if props is None: |
993 |
raise NameError('Path does not exist')
|
|
992 |
raise ItemNotExists('Path does not exist')
|
|
994 | 993 |
return props |
995 | 994 |
|
996 | 995 |
def _get_statistics(self, node, until=None): |
... | ... | |
1008 | 1007 |
if version is None: |
1009 | 1008 |
props = self.node.version_lookup(node, inf, CLUSTER_NORMAL) |
1010 | 1009 |
if props is None: |
1011 |
raise NameError('Object does not exist')
|
|
1010 |
raise ItemNotExists('Object does not exist')
|
|
1012 | 1011 |
else: |
1013 | 1012 |
try: |
1014 | 1013 |
version = int(version) |
1015 | 1014 |
except ValueError: |
1016 |
raise IndexError('Version does not exist')
|
|
1015 |
raise VersionNotExists('Version does not exist')
|
|
1017 | 1016 |
props = self.node.version_get_properties(version) |
1018 | 1017 |
if props is None or props[self.CLUSTER] == CLUSTER_DELETED: |
1019 |
raise IndexError('Version does not exist')
|
|
1018 |
raise VersionNotExists('Version does not exist')
|
|
1020 | 1019 |
return props |
1021 | 1020 |
|
1022 |
def _get_versions(self, nodes, version=None): |
|
1023 |
if version is None: |
|
1024 |
props = self.node.version_lookup_bulk(nodes, inf, CLUSTER_NORMAL) |
|
1025 |
if not props: |
|
1026 |
raise NameError('Object does not exist') |
|
1027 |
else: |
|
1028 |
try: |
|
1029 |
version = int(version) |
|
1030 |
except ValueError: |
|
1031 |
raise IndexError('Version does not exist') |
|
1032 |
props = self.node.version_get_properties(version) |
|
1033 |
if props is None or props[self.CLUSTER] == CLUSTER_DELETED: |
|
1034 |
raise IndexError('Version does not exist') |
|
1035 |
return props |
|
1021 |
def _get_versions(self, nodes): |
|
1022 |
return self.node.version_lookup_bulk(nodes, inf, CLUSTER_NORMAL) |
|
1036 | 1023 |
|
1037 | 1024 |
def _put_version_duplicate(self, user, node, src_node=None, size=None, type=None, hash=None, checksum=None, cluster=CLUSTER_NORMAL, is_copy=False): |
1038 | 1025 |
"""Create a new version of the node.""" |
Also available in: Unified diff