Revision bb4eafc6 pithos/backends/modular.py
b/pithos/backends/modular.py | ||
---|---|---|
44 | 44 |
|
45 | 45 |
inf = float('inf') |
46 | 46 |
|
47 |
ULTIMATE_ANSWER = 42 |
|
48 |
|
|
47 | 49 |
|
48 | 50 |
logger = logging.getLogger(__name__) |
49 | 51 |
|
... | ... | |
492 | 494 |
|
493 | 495 |
@backend_method |
494 | 496 |
def get_object_public(self, user, account, container, name): |
495 |
"""Return the public URL of the object if applicable."""
|
|
497 |
"""Return the public id of the object if applicable."""
|
|
496 | 498 |
|
497 | 499 |
logger.debug("get_object_public: %s %s %s", account, container, name) |
498 | 500 |
self._can_read(user, account, container, name) |
499 | 501 |
path = self._lookup_object(account, container, name)[0] |
500 |
if self.permissions.public_check(path): |
|
501 |
return '/public/' + path |
|
502 |
return None |
|
502 |
p = self.permissions.public_get(path) |
|
503 |
if p is not None: |
|
504 |
p += ULTIMATE_ANSWER |
|
505 |
return p |
|
503 | 506 |
|
504 | 507 |
@backend_method |
505 | 508 |
def update_object_public(self, user, account, container, name, public): |
... | ... | |
651 | 654 |
versions = self.node.node_get_versions(node) |
652 | 655 |
return [[x[self.SERIAL], x[self.MTIME]] for x in versions if x[self.CLUSTER] != CLUSTER_DELETED] |
653 | 656 |
|
657 |
@backend_method |
|
658 |
def get_public(self, user, public): |
|
659 |
"""Return the (account, container, name) for the public id given.""" |
|
660 |
logger.debug("get_public: %s", public) |
|
661 |
if public is None or public < ULTIMATE_ANSWER: |
|
662 |
raise NameError |
|
663 |
path = self.permissions.public_path(public - ULTIMATE_ANSWER) |
|
664 |
account, container, name = path.split('/', 2) |
|
665 |
self._can_read(user, account, container, name) |
|
666 |
return (account, container, name) |
|
667 |
|
|
654 | 668 |
@backend_method(autocommit=0) |
655 | 669 |
def get_block(self, hash): |
656 | 670 |
"""Return a block's data.""" |
Also available in: Unified diff