~ttx/glance/cactus-final-version

« back to all changes in this revision

Viewing changes to glance/registry/db/api.py

  • Committer: Tarmac
  • Author(s): Dan Prince
  • Date: 2011-03-28 18:02:21 UTC
  • mfrom: (94.1.1 glance_property_delete)
  • Revision ID: tarmac-20110328180221-a3sdprzgsphllahu
Update the glance registry so that it marks properties as deleted if they are no longer exist when images are updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
256
256
        else:
257
257
            image_property_create(context, prop_values, session=session)
258
258
 
 
259
    for key in orig_properties.keys():
 
260
        if not key in properties:
 
261
            prop_ref = orig_properties[key]
 
262
            image_property_delete(context, prop_ref, session=session)
 
263
 
259
264
 
260
265
def image_property_create(context, values, session=None):
261
266
    """Create an ImageProperty object"""
277
282
    return prop_ref
278
283
 
279
284
 
 
285
def image_property_delete(context, prop_ref, session=None):
 
286
    """Used internally by image_property_create and image_property_update
 
287
    """
 
288
    prop_ref.update(dict(deleted=True))
 
289
    prop_ref.save(session=session)
 
290
    return prop_ref
 
291
 
 
292
 
280
293
# pylint: disable-msg=C0111
281
294
def _deleted(context):
282
295
    """Calculates whether to include deleted objects based on context.