Revision 804e8fe7

b/pithos/api/functions.py
43 43

  
44 44
from pithos.api.faults import (Fault, NotModified, BadRequest, Unauthorized, ItemNotFound, Conflict,
45 45
    LengthRequired, PreconditionFailed, RangeNotSatisfiable, UnprocessableEntity)
46
from pithos.api.util import (format_header_key, printable_header_dict, get_account_headers,
46
from pithos.api.util import (rename_meta_key, format_header_key, printable_header_dict, get_account_headers,
47 47
    put_account_headers, get_container_headers, put_container_headers, get_object_headers, put_object_headers,
48 48
    update_manifest_meta, update_sharing_meta, update_public_meta, validate_modification_preconditions,
49 49
    validate_matching_preconditions, split_container_object_string, copy_or_move_object,
......
162 162
        except NotAllowedError:
163 163
            raise Unauthorized('Access denied')
164 164
        else:
165
            rename_meta_key(meta, 'modified', 'last_modified')
166
            rename_meta_key(meta, 'until_timestamp', 'x_account_until_timestamp')
165 167
            for k, v in groups.iteritems():
166 168
                meta['X-Container-Group-' + k] = ','.join(v)
167 169
            account_meta.append(printable_header_dict(meta))
......
270 272
        except NameError:
271 273
            pass
272 274
        else:
275
            rename_meta_key(meta, 'modified', 'last_modified')
276
            rename_meta_key(meta, 'until_timestamp', 'x_container_until_timestamp')
273 277
            for k, v in policy.iteritems():
274 278
                meta['X-Container-Policy-' + k] = v
275 279
            container_meta.append(printable_header_dict(meta))
......
472 476
            except NameError:
473 477
                pass
474 478
            else:
479
                rename_meta_key(meta, 'modified', 'last_modified')
480
                rename_meta_key(meta, 'modified_by', 'x_object_modified_by')
481
                rename_meta_key(meta, 'version', 'x_object_version')
482
                rename_meta_key(meta, 'version_timestamp', 'x_object_version_timestamp')
475 483
                update_sharing_meta(permissions, v_account, v_container, x[0], meta)
476 484
                update_public_meta(public, meta)
477 485
                object_meta.append(printable_header_dict(meta))
b/pithos/api/util.py
59 59
logger = logging.getLogger(__name__)
60 60

  
61 61

  
62
def rename_meta_key(d, old, new):
63
    if old not in d:
64
        return
65
    d[new] = d[old]
66
    del(d[old])
67

  
62 68
def printable_header_dict(d):
63 69
    """Format a meta dictionary for printing out json/xml.
64 70
    
65
    Convert all keys to lower case and replace dashes to underscores.
66
    Change 'modified' key from backend to 'last_modified' and format date.
71
    Convert all keys to lower case and replace dashes with underscores.
72
    Format 'last_modified' timestamp.
67 73
    """
68 74
    
69
    if 'modified' in d:
70
        d['last_modified'] = datetime.datetime.fromtimestamp(int(d['modified'])).isoformat()
71
        del(d['modified'])
75
    d['last_modified'] = datetime.datetime.fromtimestamp(int(d['last_modified'])).isoformat()
72 76
    return dict([(k.lower().replace('-', '_'), v) for k, v in d.iteritems()])
73 77

  
74 78
def format_header_key(k):

Also available in: Unified diff