예제 #1
0
 def delete_bundles(self, uuids):
     '''
     Delete bundles with the given uuids.
     '''
     self._check_not_running(uuids)
     with self.engine.begin() as connection:
         # We must delete bundles rows in the opposite order that we create them
         # to avoid foreign-key constraint failures.
         connection.execute(cl_worksheet_item.delete().where(
             cl_worksheet_item.c.bundle_uuid.in_(uuids)
         ))
         connection.execute(cl_bundle_metadata.delete().where(
             cl_bundle_metadata.c.bundle_uuid.in_(uuids)
         ))
         connection.execute(cl_bundle_dependency.delete().where(
             cl_bundle_dependency.c.child_uuid.in_(uuids)
         ))
         connection.execute(cl_bundle.delete().where(
             cl_bundle.c.uuid.in_(uuids)
         ))
예제 #2
0
    def delete_bundle_tree(self, uuids, force=False):
        '''
        Delete bundles with the given uuids and all bundles that are (direct or
        indirect) descendents of them.

        If force is False, there should be no descendents of the given bundles.
        '''
        children = self.get_children(uuid=uuids)
        if children:
            precondition(force, 'Bundles depend on %s:\n  %s' % (
              self.get_bundle(uuids[0]),
              '\n  '.join(str(child) for child in children),
            ))
            self.delete_bundle_tree([child.uuid for child in children], force=True)
        with self.engine.begin() as connection:
            # We must delete bundles rows in the opposite order that we create them
            # to avoid foreign-key constraint failures.
            connection.execute(cl_bundle_metadata.delete().where(
              cl_bundle_metadata.c.bundle_uuid.in_(uuids)
            ))
            connection.execute(cl_bundle_dependency.delete().where(
              cl_bundle_dependency.c.child_uuid.in_(uuids)
            ))
            connection.execute(cl_bundle.delete().where(cl_bundle.c.uuid.in_(uuids)))