Revision 78fa9134 snf-cyclades-app/synnefo/plankton/backend.py
b/snf-cyclades-app/synnefo/plankton/backend.py | ||
---|---|---|
63 | 63 |
from django.conf import settings |
64 | 64 |
from django.utils import importlib |
65 | 65 |
from pithos.backends.base import NotAllowedError, VersionNotExists |
66 |
from synnefo.util.text import uenc |
|
67 |
|
|
66 | 68 |
|
67 | 69 |
logger = logging.getLogger(__name__) |
68 | 70 |
|
... | ... | |
100 | 102 |
|
101 | 103 |
def split_url(url): |
102 | 104 |
"""Returns (accout, container, object) from a url string""" |
103 |
t = url.split('/', 4) |
|
104 |
assert t[0] == "pithos:", "Invalid url" |
|
105 |
assert len(t) == 5, "Invalid url" |
|
106 |
return t[2:5] |
|
105 |
try: |
|
106 |
assert(isinstance(url, basestring)) |
|
107 |
t = url.split('/', 4) |
|
108 |
assert t[0] == "pithos:", "Invalid url" |
|
109 |
assert len(t) == 5, "Invalid url" |
|
110 |
return t[2:5] |
|
111 |
except AssertionError: |
|
112 |
raise InvalidLocation("Invalid location '%s" % url) |
|
107 | 113 |
|
108 | 114 |
|
109 | 115 |
def format_timestamp(t): |
... | ... | |
205 | 211 |
"""Update object's metadata.""" |
206 | 212 |
account, container, name = split_url(image_url) |
207 | 213 |
|
208 |
prefixed = [(PLANKTON_PREFIX + k, v) for k, v in meta.items() |
|
214 |
prefixed = [(PLANKTON_PREFIX + uenc(k), uenc(v)) |
|
215 |
for k, v in meta.items() |
|
209 | 216 |
if k in PLANKTON_META or k.startswith(PROPERTY_PREFIX)] |
210 | 217 |
prefixed = dict(prefixed) |
211 | 218 |
|
... | ... | |
484 | 491 |
pass |
485 | 492 |
|
486 | 493 |
|
494 |
class InvalidLocation(ImageBackendError): |
|
495 |
pass |
|
496 |
|
|
497 |
|
|
487 | 498 |
def image_to_dict(image_url, meta, permissions): |
488 | 499 |
"""Render an image to a dictionary""" |
489 | 500 |
account, container, name = split_url(image_url) |
Also available in: Unified diff