Example #1
0
    for relationship in serializer.as_query():
      self.delete_relationship(relationship)
      deleted += 1

    db.session.commit()

    return flask.jsonify({"count": deleted})

  def delete_relationship(self, relationship):
    """Send post deletion signals."""
    db.session.delete(relationship)

    signals.Restful.model_deleted.send(
        models.Relationship, obj=relationship, service=self)
    modified_objects = services_common.get_modified_objects(db.session)
    event = log_event.log_event(db.session, relationship)
    cache_utils.update_memcache_before_commit(
        self.request, modified_objects,
        services_common.CACHE_EXPIRY_COLLECTION)

    db.session.flush()

    services_common.update_snapshot_index(modified_objects)
    cache_utils.update_memcache_after_commit(flask.request)
    signals.Restful.model_deleted_after_commit.send(
        models.Relationship, obj=relationship, service=self, event=event)
    services_common.send_event_job(event)

app.add_url_rule('/api/relationships/unmap',
                 view_func=UnmapObjectsView.as_view('unmap_objects'))
Example #2
0
    for relationship in serializer.as_query():
      self.delete_relationship(relationship)
      deleted += 1

    db.session.commit()

    return flask.jsonify({"count": deleted})

  def delete_relationship(self, relationship):
    """Send post deletion signals."""
    db.session.delete(relationship)

    signals.Restful.model_deleted.send(
        models.Relationship, obj=relationship, service=self)
    modified_objects = services_common.get_modified_objects(db.session)
    event = log_event.log_event(db.session, relationship)
    cache_utils.update_memcache_before_commit(
        self.request, modified_objects,
        services_common.CACHE_EXPIRY_COLLECTION)

    db.session.flush()

    services_common.update_snapshot_index(modified_objects)
    cache_utils.update_memcache_after_commit(flask.request)
    signals.Restful.model_deleted_after_commit.send(
        models.Relationship, obj=relationship, service=self, event=event)
    services_common.send_event_job(event)

app.add_url_rule('/api/relationships/unmap',
                 view_func=UnmapObjectsView.as_view('unmap_objects'))