Merge lp:~rconradharris/glance/use_datetime_obj into lp:~hudson-openstack/glance/trunk
- use_datetime_obj
- Merge into trunk
Proposed by
Rick Harris
Status: | Merged |
---|---|
Approved by: | Jay Pipes |
Approved revision: | 29 |
Merged at revision: | 28 |
Proposed branch: | lp:~rconradharris/glance/use_datetime_obj |
Merge into: | lp:~hudson-openstack/glance/trunk |
Diff against target: |
394 lines (+68/-77) 11 files modified
glance/client.py (+1/-1) glance/common/db/__init__.py (+0/-1) glance/common/wsgi.py (+5/-5) glance/registry/__init__.py (+1/-1) glance/registry/db/sqlalchemy/api.py (+37/-33) glance/registry/db/sqlalchemy/models.py (+3/-17) glance/registry/server.py (+7/-8) glance/server.py (+10/-7) glance/store/filesystem.py (+2/-2) glance/store/http.py (+1/-1) glance/store/swift.py (+1/-1) |
To merge this branch: | bzr merge lp:~rconradharris/glance/use_datetime_obj |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jay Pipes (community) | Approve | ||
Review via email: mp+44493@code.launchpad.net |
Commit message
Description of the change
Converts timestamp attributes to datetime objects before persisting.
Refactors image_update and image_create to use the same basic code.
To post a comment you must log in.
- 29. By Rick Harris
-
Adding __protected_
attributes_ _, some PEP8 cleanups
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'glance/client.py' | |||
2 | --- glance/client.py 2010-12-21 05:30:04 +0000 | |||
3 | +++ glance/client.py 2010-12-23 19:24:08 +0000 | |||
4 | @@ -255,7 +255,7 @@ | |||
5 | 255 | headers['content-type'] = 'application/octet-stream' | 255 | headers['content-type'] = 'application/octet-stream' |
6 | 256 | else: | 256 | else: |
7 | 257 | body = None | 257 | body = None |
9 | 258 | 258 | ||
10 | 259 | res = self.do_request("POST", "/images", body, headers) | 259 | res = self.do_request("POST", "/images", body, headers) |
11 | 260 | data = json.loads(res.read()) | 260 | data = json.loads(res.read()) |
12 | 261 | return data['image']['id'] | 261 | return data['image']['id'] |
13 | 262 | 262 | ||
14 | === modified file 'glance/common/db/__init__.py' | |||
15 | --- glance/common/db/__init__.py 2010-10-01 19:51:29 +0000 | |||
16 | +++ glance/common/db/__init__.py 2010-12-23 19:24:08 +0000 | |||
17 | @@ -19,4 +19,3 @@ | |||
18 | 19 | """ | 19 | """ |
19 | 20 | DB abstraction for Nova and Glance | 20 | DB abstraction for Nova and Glance |
20 | 21 | """ | 21 | """ |
21 | 22 | |||
22 | 23 | 22 | ||
23 | === modified file 'glance/common/wsgi.py' | |||
24 | --- glance/common/wsgi.py 2010-12-18 18:00:21 +0000 | |||
25 | +++ glance/common/wsgi.py 2010-12-23 19:24:08 +0000 | |||
26 | @@ -21,6 +21,7 @@ | |||
27 | 21 | Utility methods for working with WSGI servers | 21 | Utility methods for working with WSGI servers |
28 | 22 | """ | 22 | """ |
29 | 23 | 23 | ||
30 | 24 | import json | ||
31 | 24 | import logging | 25 | import logging |
32 | 25 | import sys | 26 | import sys |
33 | 26 | import datetime | 27 | import datetime |
34 | @@ -115,11 +116,11 @@ | |||
35 | 115 | behavior. | 116 | behavior. |
36 | 116 | """ | 117 | """ |
37 | 117 | 118 | ||
39 | 118 | def __init__(self, application): # pylint: disable-msg=W0231 | 119 | def __init__(self, application): # pylint: disable-msg=W0231 |
40 | 119 | self.application = application | 120 | self.application = application |
41 | 120 | 121 | ||
42 | 121 | @webob.dec.wsgify | 122 | @webob.dec.wsgify |
44 | 122 | def __call__(self, req): # pylint: disable-msg=W0221 | 123 | def __call__(self, req): # pylint: disable-msg=W0221 |
45 | 123 | """Override to implement middleware behavior.""" | 124 | """Override to implement middleware behavior.""" |
46 | 124 | return self.application | 125 | return self.application |
47 | 125 | 126 | ||
48 | @@ -237,7 +238,7 @@ | |||
49 | 237 | arg_dict['req'] = req | 238 | arg_dict['req'] = req |
50 | 238 | result = method(**arg_dict) | 239 | result = method(**arg_dict) |
51 | 239 | if type(result) is dict: | 240 | if type(result) is dict: |
53 | 240 | return self._serialize(result, req) | 241 | return self._serialize(result, req) |
54 | 241 | else: | 242 | else: |
55 | 242 | return result | 243 | return result |
56 | 243 | 244 | ||
57 | @@ -282,7 +283,6 @@ | |||
58 | 282 | return self._methods.get(mimetype, repr)(data) | 283 | return self._methods.get(mimetype, repr)(data) |
59 | 283 | 284 | ||
60 | 284 | def _to_json(self, data): | 285 | def _to_json(self, data): |
61 | 285 | import json | ||
62 | 286 | def sanitizer(obj): | 286 | def sanitizer(obj): |
63 | 287 | if isinstance(obj, datetime.datetime): | 287 | if isinstance(obj, datetime.datetime): |
64 | 288 | return obj.isoformat() | 288 | return obj.isoformat() |
65 | @@ -320,7 +320,7 @@ | |||
66 | 320 | else: | 320 | else: |
67 | 321 | node = self._to_xml_node(doc, metadata, k, v) | 321 | node = self._to_xml_node(doc, metadata, k, v) |
68 | 322 | result.appendChild(node) | 322 | result.appendChild(node) |
70 | 323 | else: # atom | 323 | else: # atom |
71 | 324 | node = doc.createTextNode(str(data)) | 324 | node = doc.createTextNode(str(data)) |
72 | 325 | result.appendChild(node) | 325 | result.appendChild(node) |
73 | 326 | return result | 326 | return result |
74 | 327 | 327 | ||
75 | === modified file 'glance/registry/__init__.py' | |||
76 | --- glance/registry/__init__.py 2010-12-14 15:10:54 +0000 | |||
77 | +++ glance/registry/__init__.py 2010-12-23 19:24:08 +0000 | |||
78 | @@ -17,7 +17,7 @@ | |||
79 | 17 | # under the License. | 17 | # under the License. |
80 | 18 | 18 | ||
81 | 19 | """ | 19 | """ |
83 | 20 | Registry API | 20 | Registry API |
84 | 21 | """ | 21 | """ |
85 | 22 | 22 | ||
86 | 23 | from glance.registry import client | 23 | from glance.registry import client |
87 | 24 | 24 | ||
88 | === modified file 'glance/registry/db/sqlalchemy/api.py' | |||
89 | --- glance/registry/db/sqlalchemy/api.py 2010-12-21 15:07:16 +0000 | |||
90 | +++ glance/registry/db/sqlalchemy/api.py 2010-12-23 19:24:08 +0000 | |||
91 | @@ -52,19 +52,7 @@ | |||
92 | 52 | 52 | ||
93 | 53 | 53 | ||
94 | 54 | def image_create(_context, values): | 54 | def image_create(_context, values): |
108 | 55 | values['size'] = int(values['size']) | 55 | return _image_update(_context, values, None) |
96 | 56 | values['is_public'] = bool(values.get('is_public', False)) | ||
97 | 57 | properties = values.pop('properties', {}) | ||
98 | 58 | |||
99 | 59 | image_ref = models.Image() | ||
100 | 60 | image_ref.update(values) | ||
101 | 61 | image_ref.save() | ||
102 | 62 | |||
103 | 63 | for key, value in properties.iteritems(): | ||
104 | 64 | prop_values = {'image_id': image_ref.id, 'key': key, 'value': value} | ||
105 | 65 | image_property_create(_context, prop_values) | ||
106 | 66 | |||
107 | 67 | return image_get(_context, image_ref.id) | ||
109 | 68 | 56 | ||
110 | 69 | 57 | ||
111 | 70 | def image_destroy(_context, image_id): | 58 | def image_destroy(_context, image_id): |
112 | @@ -109,13 +97,47 @@ | |||
113 | 109 | 97 | ||
114 | 110 | 98 | ||
115 | 111 | def image_update(_context, image_id, values): | 99 | def image_update(_context, image_id, values): |
116 | 100 | return _image_update(_context, values, image_id) | ||
117 | 101 | |||
118 | 102 | |||
119 | 103 | ################### | ||
120 | 104 | |||
121 | 105 | |||
122 | 106 | def image_property_create(_context, values): | ||
123 | 107 | _drop_protected_attrs(models.Image, values) | ||
124 | 108 | image_property_ref = models.ImageProperty() | ||
125 | 109 | image_property_ref.update(values) | ||
126 | 110 | image_property_ref.save() | ||
127 | 111 | return image_property_ref | ||
128 | 112 | |||
129 | 113 | |||
130 | 114 | def _drop_protected_attrs(model_class, values): | ||
131 | 115 | """Removed protected attributes from values dictionary using the models | ||
132 | 116 | __protected_attributes__ field. | ||
133 | 117 | """ | ||
134 | 118 | for attr in model_class.__protected_attributes__: | ||
135 | 119 | if attr in values: | ||
136 | 120 | del values[attr] | ||
137 | 121 | |||
138 | 122 | |||
139 | 123 | def _image_update(_context, values, image_id): | ||
140 | 124 | """Used internally by image_create and image_update | ||
141 | 125 | |||
142 | 126 | :param image_id: If None, create the image, otherwise, find and update it | ||
143 | 127 | """ | ||
144 | 112 | session = get_session() | 128 | session = get_session() |
145 | 113 | with session.begin(): | 129 | with session.begin(): |
146 | 130 | _drop_protected_attrs(models.Image, values) | ||
147 | 131 | |||
148 | 114 | values['size'] = int(values['size']) | 132 | values['size'] = int(values['size']) |
149 | 115 | values['is_public'] = bool(values.get('is_public', False)) | 133 | values['is_public'] = bool(values.get('is_public', False)) |
150 | 116 | properties = values.pop('properties', {}) | 134 | properties = values.pop('properties', {}) |
151 | 117 | 135 | ||
153 | 118 | image_ref = models.Image.find(image_id, session=session) | 136 | if image_id: |
154 | 137 | image_ref = models.Image.find(image_id, session=session) | ||
155 | 138 | else: | ||
156 | 139 | image_ref = models.Image() | ||
157 | 140 | |||
158 | 119 | image_ref.update(values) | 141 | image_ref.update(values) |
159 | 120 | image_ref.save(session=session) | 142 | image_ref.save(session=session) |
160 | 121 | 143 | ||
161 | @@ -123,22 +145,4 @@ | |||
162 | 123 | prop_values = {'image_id': image_ref.id, 'key': key, 'value': value} | 145 | prop_values = {'image_id': image_ref.id, 'key': key, 'value': value} |
163 | 124 | image_property_create(_context, prop_values) | 146 | image_property_create(_context, prop_values) |
164 | 125 | 147 | ||
184 | 126 | 148 | return image_get(_context, image_ref.id) | |
166 | 127 | ################### | ||
167 | 128 | |||
168 | 129 | |||
169 | 130 | def image_file_create(_context, values): | ||
170 | 131 | image_file_ref = models.ImageFile() | ||
171 | 132 | image_file_ref.update(values) | ||
172 | 133 | image_file_ref.save() | ||
173 | 134 | return image_file_ref | ||
174 | 135 | |||
175 | 136 | |||
176 | 137 | ################### | ||
177 | 138 | |||
178 | 139 | |||
179 | 140 | def image_property_create(_context, values): | ||
180 | 141 | image_property_ref = models.ImageProperty() | ||
181 | 142 | image_property_ref.update(values) | ||
182 | 143 | image_property_ref.save() | ||
183 | 144 | return image_property_ref | ||
185 | 145 | 149 | ||
186 | === modified file 'glance/registry/db/sqlalchemy/models.py' | |||
187 | --- glance/registry/db/sqlalchemy/models.py 2010-12-16 22:04:58 +0000 | |||
188 | +++ glance/registry/db/sqlalchemy/models.py 2010-12-23 19:24:08 +0000 | |||
189 | @@ -45,6 +45,9 @@ | |||
190 | 45 | __table_args__ = {'mysql_engine': 'InnoDB'} | 45 | __table_args__ = {'mysql_engine': 'InnoDB'} |
191 | 46 | __table_initialized__ = False | 46 | __table_initialized__ = False |
192 | 47 | __prefix__ = 'none' | 47 | __prefix__ = 'none' |
193 | 48 | __protected_attributes__ = set([ | ||
194 | 49 | "created_at", "updated_at", "deleted_at", "deleted"]) | ||
195 | 50 | |||
196 | 48 | created_at = Column(DateTime, default=datetime.datetime.utcnow) | 51 | created_at = Column(DateTime, default=datetime.datetime.utcnow) |
197 | 49 | updated_at = Column(DateTime, onupdate=datetime.datetime.utcnow) | 52 | updated_at = Column(DateTime, onupdate=datetime.datetime.utcnow) |
198 | 50 | deleted_at = Column(DateTime) | 53 | deleted_at = Column(DateTime) |
199 | @@ -160,23 +163,6 @@ | |||
200 | 160 | raise exception.Invalid("Invalid status '%s' for image." % status) | 163 | raise exception.Invalid("Invalid status '%s' for image." % status) |
201 | 161 | return status | 164 | return status |
202 | 162 | 165 | ||
203 | 163 | # TODO(sirp): should these be stored as properties? | ||
204 | 164 | #user_id = Column(String(255)) | ||
205 | 165 | #project_id = Column(String(255)) | ||
206 | 166 | #arch = Column(String(255)) | ||
207 | 167 | #default_kernel_id = Column(String(255)) | ||
208 | 168 | #default_ramdisk_id = Column(String(255)) | ||
209 | 169 | # | ||
210 | 170 | #@validates('default_kernel_id') | ||
211 | 171 | #def validate_kernel_id(self, key, val): | ||
212 | 172 | # if val != 'machine': | ||
213 | 173 | # assert(val is None) | ||
214 | 174 | # | ||
215 | 175 | #@validates('default_ramdisk_id') | ||
216 | 176 | #def validate_ramdisk_id(self, key, val): | ||
217 | 177 | # if val != 'machine': | ||
218 | 178 | # assert(val is None) | ||
219 | 179 | |||
220 | 180 | 166 | ||
221 | 181 | class ImageProperty(BASE, ModelBase): | 167 | class ImageProperty(BASE, ModelBase): |
222 | 182 | """Represents an image properties in the datastore""" | 168 | """Represents an image properties in the datastore""" |
223 | 183 | 169 | ||
224 | === modified file 'glance/registry/server.py' | |||
225 | --- glance/registry/server.py 2010-12-18 18:00:21 +0000 | |||
226 | +++ glance/registry/server.py 2010-12-23 19:24:08 +0000 | |||
227 | @@ -28,12 +28,11 @@ | |||
228 | 28 | 28 | ||
229 | 29 | 29 | ||
230 | 30 | class ImageController(wsgi.Controller): | 30 | class ImageController(wsgi.Controller): |
231 | 31 | |||
232 | 32 | """Image Controller """ | 31 | """Image Controller """ |
234 | 33 | 32 | ||
235 | 34 | def index(self, req): | 33 | def index(self, req): |
236 | 35 | """Return basic information for all public, non-deleted images | 34 | """Return basic information for all public, non-deleted images |
238 | 36 | 35 | ||
239 | 37 | :param req: the Request object coming from the wsgi layer | 36 | :param req: the Request object coming from the wsgi layer |
240 | 38 | :retval a mapping of the following form:: | 37 | :retval a mapping of the following form:: |
241 | 39 | 38 | ||
242 | @@ -42,7 +41,7 @@ | |||
243 | 42 | Where image_list is a sequence of mappings:: | 41 | Where image_list is a sequence of mappings:: |
244 | 43 | 42 | ||
245 | 44 | {'id': image_id, 'name': image_name} | 43 | {'id': image_id, 'name': image_name} |
247 | 45 | 44 | ||
248 | 46 | """ | 45 | """ |
249 | 47 | images = db.image_get_all_public(None) | 46 | images = db.image_get_all_public(None) |
250 | 48 | image_dicts = [dict(id=i['id'], name=i['name']) for i in images] | 47 | image_dicts = [dict(id=i['id'], name=i['name']) for i in images] |
251 | @@ -50,7 +49,7 @@ | |||
252 | 50 | 49 | ||
253 | 51 | def detail(self, req): | 50 | def detail(self, req): |
254 | 52 | """Return detailed information for all public, non-deleted images | 51 | """Return detailed information for all public, non-deleted images |
256 | 53 | 52 | ||
257 | 54 | :param req: the Request object coming from the wsgi layer | 53 | :param req: the Request object coming from the wsgi layer |
258 | 55 | :retval a mapping of the following form:: | 54 | :retval a mapping of the following form:: |
259 | 56 | 55 | ||
260 | @@ -58,7 +57,7 @@ | |||
261 | 58 | 57 | ||
262 | 59 | Where image_list is a sequence of mappings containing | 58 | Where image_list is a sequence of mappings containing |
263 | 60 | all image model fields. | 59 | all image model fields. |
265 | 61 | 60 | ||
266 | 62 | """ | 61 | """ |
267 | 63 | images = db.image_get_all_public(None) | 62 | images = db.image_get_all_public(None) |
268 | 64 | image_dicts = [make_image_dict(i) for i in images] | 63 | image_dicts = [make_image_dict(i) for i in images] |
269 | @@ -70,7 +69,7 @@ | |||
270 | 70 | image = db.image_get(None, id) | 69 | image = db.image_get(None, id) |
271 | 71 | except exception.NotFound: | 70 | except exception.NotFound: |
272 | 72 | raise exc.HTTPNotFound() | 71 | raise exc.HTTPNotFound() |
274 | 73 | 72 | ||
275 | 74 | return dict(image=make_image_dict(image)) | 73 | return dict(image=make_image_dict(image)) |
276 | 75 | 74 | ||
277 | 76 | def delete(self, req, id): | 75 | def delete(self, req, id): |
278 | @@ -153,7 +152,7 @@ | |||
279 | 153 | Create a dict representation of an image which we can use to | 152 | Create a dict representation of an image which we can use to |
280 | 154 | serialize the image. | 153 | serialize the image. |
281 | 155 | """ | 154 | """ |
283 | 156 | 155 | ||
284 | 157 | def _fetch_attrs(d, attrs): | 156 | def _fetch_attrs(d, attrs): |
285 | 158 | return dict([(a, d[a]) for a in attrs | 157 | return dict([(a, d[a]) for a in attrs |
286 | 159 | if a in d.keys()]) | 158 | if a in d.keys()]) |
287 | 160 | 159 | ||
288 | === modified file 'glance/server.py' | |||
289 | --- glance/server.py 2010-12-21 05:30:04 +0000 | |||
290 | +++ glance/server.py 2010-12-23 19:24:08 +0000 | |||
291 | @@ -57,10 +57,10 @@ | |||
292 | 57 | 57 | ||
293 | 58 | """ | 58 | """ |
294 | 59 | Main WSGI application controller for Glance. | 59 | Main WSGI application controller for Glance. |
296 | 60 | 60 | ||
297 | 61 | The Glance API is a RESTful web service for image data. The API | 61 | The Glance API is a RESTful web service for image data. The API |
298 | 62 | is as follows:: | 62 | is as follows:: |
300 | 63 | 63 | ||
301 | 64 | GET /images -- Returns a set of brief metadata about images | 64 | GET /images -- Returns a set of brief metadata about images |
302 | 65 | GET /images/detail -- Returns a set of detailed metadata about | 65 | GET /images/detail -- Returns a set of detailed metadata about |
303 | 66 | images | 66 | images |
304 | @@ -72,7 +72,7 @@ | |||
305 | 72 | image data is immutable once stored) | 72 | image data is immutable once stored) |
306 | 73 | DELETE /images/<ID> -- Delete the image with id <ID> | 73 | DELETE /images/<ID> -- Delete the image with id <ID> |
307 | 74 | """ | 74 | """ |
309 | 75 | 75 | ||
310 | 76 | def index(self, req): | 76 | def index(self, req): |
311 | 77 | """ | 77 | """ |
312 | 78 | Returns the following information for all public, available images: | 78 | Returns the following information for all public, available images: |
313 | @@ -81,7 +81,7 @@ | |||
314 | 81 | * name -- The name of the image | 81 | * name -- The name of the image |
315 | 82 | * size -- Size of image data in bytes | 82 | * size -- Size of image data in bytes |
316 | 83 | * type -- One of 'kernel', 'ramdisk', 'raw', or 'machine' | 83 | * type -- One of 'kernel', 'ramdisk', 'raw', or 'machine' |
318 | 84 | 84 | ||
319 | 85 | :param request: The WSGI/Webob Request object | 85 | :param request: The WSGI/Webob Request object |
320 | 86 | :retval The response body is a mapping of the following form:: | 86 | :retval The response body is a mapping of the following form:: |
321 | 87 | 87 | ||
322 | @@ -98,7 +98,7 @@ | |||
323 | 98 | def detail(self, req): | 98 | def detail(self, req): |
324 | 99 | """ | 99 | """ |
325 | 100 | Returns detailed information for all public, available images | 100 | Returns detailed information for all public, available images |
327 | 101 | 101 | ||
328 | 102 | :param request: The WSGI/Webob Request object | 102 | :param request: The WSGI/Webob Request object |
329 | 103 | :retval The response body is a mapping of the following form:: | 103 | :retval The response body is a mapping of the following form:: |
330 | 104 | 104 | ||
331 | @@ -225,6 +225,7 @@ | |||
332 | 225 | try: | 225 | try: |
333 | 226 | location = store.add(image_meta['id'], req.body) | 226 | location = store.add(image_meta['id'], req.body) |
334 | 227 | except exception.Duplicate, e: | 227 | except exception.Duplicate, e: |
335 | 228 | logging.error("Error adding image to store: %s", str(e)) | ||
336 | 228 | return HTTPConflict(str(e), request=req) | 229 | return HTTPConflict(str(e), request=req) |
337 | 229 | image_meta['status'] = 'available' | 230 | image_meta['status'] = 'available' |
338 | 230 | image_meta['location'] = location | 231 | image_meta['location'] = location |
339 | @@ -233,8 +234,10 @@ | |||
340 | 233 | return dict(image=image_meta) | 234 | return dict(image=image_meta) |
341 | 234 | 235 | ||
342 | 235 | except exception.Duplicate: | 236 | except exception.Duplicate: |
345 | 236 | return HTTPConflict("An image with identifier %s already exists" | 237 | msg = "An image with identifier %s already exists"\ |
346 | 237 | % image_meta['id'], request=req) | 238 | % image_meta['id'] |
347 | 239 | logging.error(msg) | ||
348 | 240 | return HTTPConflict(msg, request=req) | ||
349 | 238 | except exception.Invalid: | 241 | except exception.Invalid: |
350 | 239 | return HTTPBadRequest() | 242 | return HTTPBadRequest() |
351 | 240 | 243 | ||
352 | 241 | 244 | ||
353 | === modified file 'glance/store/filesystem.py' | |||
354 | --- glance/store/filesystem.py 2010-12-21 05:30:04 +0000 | |||
355 | +++ glance/store/filesystem.py 2010-12-23 19:24:08 +0000 | |||
356 | @@ -66,10 +66,10 @@ | |||
357 | 66 | self.fp = None | 66 | self.fp = None |
358 | 67 | 67 | ||
359 | 68 | 68 | ||
360 | 69 | |||
361 | 70 | class FilesystemBackend(glance.store.Backend): | 69 | class FilesystemBackend(glance.store.Backend): |
362 | 71 | @classmethod | 70 | @classmethod |
364 | 72 | def get(cls, parsed_uri, opener=lambda p: open(p, "rb"), expected_size=None): | 71 | def get(cls, parsed_uri, opener=lambda p: open(p, "rb"), |
365 | 72 | expected_size=None): | ||
366 | 73 | """ Filesystem-based backend | 73 | """ Filesystem-based backend |
367 | 74 | 74 | ||
368 | 75 | file:///path/to/file.tar.gz.0 | 75 | file:///path/to/file.tar.gz.0 |
369 | 76 | 76 | ||
370 | === modified file 'glance/store/http.py' | |||
371 | --- glance/store/http.py 2010-12-14 01:56:11 +0000 | |||
372 | +++ glance/store/http.py 2010-12-23 19:24:08 +0000 | |||
373 | @@ -29,7 +29,7 @@ | |||
374 | 29 | """ | 29 | """ |
375 | 30 | 30 | ||
376 | 31 | if conn_class: | 31 | if conn_class: |
378 | 32 | pass # use the conn_class passed in | 32 | pass # use the conn_class passed in |
379 | 33 | elif parsed_uri.scheme == "http": | 33 | elif parsed_uri.scheme == "http": |
380 | 34 | conn_class = httplib.HTTPConnection | 34 | conn_class = httplib.HTTPConnection |
381 | 35 | elif parsed_uri.scheme == "https": | 35 | elif parsed_uri.scheme == "https": |
382 | 36 | 36 | ||
383 | === modified file 'glance/store/swift.py' | |||
384 | --- glance/store/swift.py 2010-12-16 22:04:58 +0000 | |||
385 | +++ glance/store/swift.py 2010-12-23 19:24:08 +0000 | |||
386 | @@ -114,7 +114,7 @@ | |||
387 | 114 | 114 | ||
388 | 115 | def get_connection_class(conn_class): | 115 | def get_connection_class(conn_class): |
389 | 116 | if conn_class: | 116 | if conn_class: |
391 | 117 | pass # Use the provided conn_class | 117 | pass # Use the provided conn_class |
392 | 118 | else: | 118 | else: |
393 | 119 | # NOTE(sirp): A standard import statement won't work here because | 119 | # NOTE(sirp): A standard import statement won't work here because |
394 | 120 | # this file ('swift.py') is shadowing the swift module, and since | 120 | # this file ('swift.py') is shadowing the swift module, and since |
Hi!
Good stuff, Rick :) Couple quick comments:
* Please add a test case for this... easy enough to change the stub_out_db_api stuff to have (one or more) of the FIXTURES have a string datetime instead of datetime. datetime. utcnow( )...
* Please pep8 check:
** No spaces before docstring comments so """ Used internally by image_create and image_update """
should be """Used internally by image_create and image_update""" or
"""
Used internally by image_create and image_update
"""
** No newlines at end of file
** Two newlines between each module-level object and also after import statements
Cheers!
jay