← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1371837] [NEW] Metadef ORM classes should use a common delete

 

Public bug reported:

The metadef db delete functions typically have code like this:
session.delete(db_rec)
session.flush()

To be consistent with the ORM classes save() function implementation, it would be better to add a delete function
to the base metadef ORM class (i.e., GlanceMetadefBase).

Background - Both GlanceBase and GlanceMetadefBase ORM classes call oslo.db.sqlalchemy.models.ModelBase.save() for create/update.
There is no function for hard deletes in ModelBase.

The ModelBase.save function is simply:
def save(self, session)
    with session.begin(subtransactions=True):
        session.add(self)
        session.flush()
Note: See comments in ModelBase.save for more details on the need for "with session.begin(subtransactions=True_"

The new GlanceMetadefBase.delete() function should be implemented in a
way that is consistent with the oslo ModelBase.save function
implementation.

** Affects: glance
     Importance: Undecided
     Assignee: Wayne (wayne-okuma)
         Status: New

** Changed in: glance
     Assignee: (unassigned) => Wayne (wayne-okuma)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1371837

Title:
  Metadef ORM classes should use a common delete

Status in OpenStack Image Registry and Delivery Service (Glance):
  New

Bug description:
  The metadef db delete functions typically have code like this:
  session.delete(db_rec)
  session.flush()

  To be consistent with the ORM classes save() function implementation, it would be better to add a delete function
  to the base metadef ORM class (i.e., GlanceMetadefBase).

  Background - Both GlanceBase and GlanceMetadefBase ORM classes call oslo.db.sqlalchemy.models.ModelBase.save() for create/update.
  There is no function for hard deletes in ModelBase.

  The ModelBase.save function is simply:
  def save(self, session)
      with session.begin(subtransactions=True):
          session.add(self)
          session.flush()
  Note: See comments in ModelBase.save for more details on the need for "with session.begin(subtransactions=True_"

  The new GlanceMetadefBase.delete() function should be implemented in a
  way that is consistent with the oslo ModelBase.save function
  implementation.

To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1371837/+subscriptions


Follow ups

References