~ewanmellor/glance/lp694382

« back to all changes in this revision

Viewing changes to glance/registry/server.py

  • Committer: Tarmac
  • Author(s): Rick Harris
  • Date: 2010-12-23 19:41:59 UTC
  • mfrom: (27.1.2 use_datetime_obj)
  • Revision ID: tarmac-20101223194159-304tpg996wuo6mwf
Converts timestamp attributes to datetime objects before persisting.

Refactors image_update and image_create to use the same basic code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
 
30
30
class ImageController(wsgi.Controller):
31
 
 
32
31
    """Image Controller """
33
 
    
 
32
 
34
33
    def index(self, req):
35
34
        """Return basic information for all public, non-deleted images
36
 
        
 
35
 
37
36
        :param req: the Request object coming from the wsgi layer
38
37
        :retval a mapping of the following form::
39
38
 
42
41
        Where image_list is a sequence of mappings::
43
42
 
44
43
            {'id': image_id, 'name': image_name}
45
 
        
 
44
 
46
45
        """
47
46
        images = db.image_get_all_public(None)
48
47
        image_dicts = [dict(id=i['id'], name=i['name']) for i in images]
50
49
 
51
50
    def detail(self, req):
52
51
        """Return detailed information for all public, non-deleted images
53
 
        
 
52
 
54
53
        :param req: the Request object coming from the wsgi layer
55
54
        :retval a mapping of the following form::
56
55
 
58
57
 
59
58
        Where image_list is a sequence of mappings containing
60
59
        all image model fields.
61
 
        
 
60
 
62
61
        """
63
62
        images = db.image_get_all_public(None)
64
63
        image_dicts = [make_image_dict(i) for i in images]
70
69
            image = db.image_get(None, id)
71
70
        except exception.NotFound:
72
71
            raise exc.HTTPNotFound()
73
 
        
 
72
 
74
73
        return dict(image=make_image_dict(image))
75
74
 
76
75
    def delete(self, req, id):
153
152
    Create a dict representation of an image which we can use to
154
153
    serialize the image.
155
154
    """
156
 
    
 
155
 
157
156
    def _fetch_attrs(d, attrs):
158
157
        return dict([(a, d[a]) for a in attrs
159
158
                    if a in d.keys()])