def delete_objects(context, model, **kwargs):
 with context.session.begin(subtransactions=True):
  db_objs = get_objects(context, model, **kwargs)
  for db_obj in db_objs:
   context.session.delete(db_obj)
  return len(db_objs)

def delete_objects ( context , model , ** kwargs ) : with context . session . begin ( subtransactions = True ) : db_objs = get_objects ( context , model , ** kwargs ) for db_obj in db_objs : context . session . delete ( db_obj ) return len ( db_objs )
delete matching objects .