Moving ATTR helpers into db module
This commit is contained in:
parent
9382efb849
commit
98dc44c10e
@ -132,8 +132,7 @@ class ImageController(wsgi.Controller):
|
|||||||
def _fetch_attrs(d, attrs):
|
def _fetch_attrs(d, attrs):
|
||||||
return dict([(a, d[a]) for a in attrs])
|
return dict([(a, d[a]) for a in attrs])
|
||||||
|
|
||||||
file_attrs = db.BASE_MODEL_ATTRS | set(['location', 'size'])
|
files = [_fetch_attrs(f, db.IMAGE_FILE_ATTRS) for f in image['files']]
|
||||||
files = [_fetch_attrs(f, file_attrs) for f in image['files']]
|
|
||||||
|
|
||||||
# TODO(sirp): should this be a dict, or a list of dicts?
|
# TODO(sirp): should this be a dict, or a list of dicts?
|
||||||
# A plain dict is more convenient, but list of dicts would provide
|
# A plain dict is more convenient, but list of dicts would provide
|
||||||
@ -141,8 +140,7 @@ class ImageController(wsgi.Controller):
|
|||||||
metadata = dict((m['key'], m['value']) for m in image['metadata']
|
metadata = dict((m['key'], m['value']) for m in image['metadata']
|
||||||
if not m['deleted'])
|
if not m['deleted'])
|
||||||
|
|
||||||
image_attrs = db.BASE_MODEL_ATTRS | set(['name', 'image_type', 'status', 'is_public'])
|
image_dict = _fetch_attrs(image, db.IMAGE_ATTRS)
|
||||||
image_dict = _fetch_attrs(image, image_attrs)
|
|
||||||
|
|
||||||
image_dict['files'] = files
|
image_dict['files'] = files
|
||||||
image_dict['metadata'] = metadata
|
image_dict['metadata'] = metadata
|
||||||
|
@ -25,3 +25,8 @@ from glance.parallax.db.api import *
|
|||||||
# attributes common to all models
|
# attributes common to all models
|
||||||
BASE_MODEL_ATTRS = set(['id', 'created_at', 'updated_at', 'deleted_at',
|
BASE_MODEL_ATTRS = set(['id', 'created_at', 'updated_at', 'deleted_at',
|
||||||
'deleted'])
|
'deleted'])
|
||||||
|
|
||||||
|
IMAGE_FILE_ATTRS = BASE_MODEL_ATTRS | set(['location', 'size'])
|
||||||
|
|
||||||
|
IMAGE_ATTRS = BASE_MODEL_ATTRS | set(['name', 'image_type', 'status',
|
||||||
|
'is_public'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user