def create_new(cls, owner, id, mimetype, model, url, members=()): model_id = PackageElement._check_reference(owner, model, RESOURCE) cls._check_content_cls(mimetype, model_id, url, owner) owner._backend.create_relation(owner._id, id, mimetype, model_id, url) r = cls.instantiate(owner, id, mimetype, model_id, url) if members: r.extend(members) return r
def create_new(cls, owner, id, media, begin, end, mimetype, model, url): """ Factory method to create a new instance both in memory and backend. """ media_id = PackageElement._check_reference(owner, media, MEDIA, True) begin = int(begin) end = int(end) model_id = PackageElement._check_reference(owner, model, RESOURCE) cls._check_content_cls(mimetype, model_id, url, owner) owner._backend.create_annotation(owner._id, id, media_id, begin, end, mimetype, model_id, url) r = cls.instantiate(owner, id, media_id, begin, end, mimetype, model_id, url) if media is not media_id: # we have the instance, let's cache it now r._media = media return r
def create_new(cls, owner, id, mimetype, model, url): model_id = PackageElement._check_reference(owner, model, RESOURCE) cls._check_content_cls(mimetype, model_id, url, owner) owner._backend.create_query(owner._id, id, mimetype, model_id, url) r = cls.instantiate(owner, id, mimetype, model_id, url) return r