Revision 0efb43cd snf-cyclades-app/synnefo/plankton/backend.py

b/snf-cyclades-app/synnefo/plankton/backend.py
74 74
PLANKTON_META = ('container_format', 'disk_format', 'name',
75 75
                 'status', 'created_at')
76 76

  
77
MAX_META_KEY_LENGTH = 128 - len(PLANKTON_DOMAIN) - len(PROPERTY_PREFIX)
78
MAX_META_VALUE_LENGTH = 256
79

  
77 80
from pithos.backends.util import PithosBackendPool
78 81
_pithos_backend_pool = \
79 82
    PithosBackendPool(
......
206 209
                    if k in PLANKTON_META or k.startswith(PROPERTY_PREFIX)]
207 210
        prefixed = dict(prefixed)
208 211

  
212
        for k, v in prefixed.items():
213
            if len(k) > 128:
214
                raise InvalidMetadata('Metadata keys should be less than %s '
215
                                      'characters' % MAX_META_KEY_LENGTH)
216
            if len(v) > 256:
217
                raise InvalidMetadata('Metadata values should be less than %s '
218
                                      'characters.' % MAX_META_VALUE_LENGTH)
219

  
209 220
        self.backend.update_object_meta(self.user, account, container, name,
210 221
                                        PLANKTON_DOMAIN, prefixed, replace)
211 222
        logger.debug("User '%s' updated image '%s', meta: '%s'", self.user,
......
469 480
    pass
470 481

  
471 482

  
483
class InvalidMetadata(ImageBackendError):
484
    pass
485

  
486

  
472 487
def image_to_dict(image_url, meta, permissions):
473 488
    """Render an image to a dictionary"""
474 489
    account, container, name = split_url(image_url)

Also available in: Unified diff