def __deleteItem(self, item_id, user_login, delete_physical_file=True):
        # We should not delete Item objects from database, because
        # we do not want hanging references in HistoryRec table.
        # So we just mark Items as deleted.

        # DataRef objects are deleted from database, if there are no references to it from other alive Items.

        # TODO: Make admin users to be able to delete any files, owned by anybody.

        item = self._session.query(db.Item).get(item_id)
        if item.user_login != user_login:
            raise err.AccessError("Cannot delete item id={0} because it is owned by another user {1}."
                              .format(item_id, item.user_login))

        if item.hasTagsExceptOf(user_login):
            raise err.AccessError("Cannot delete item id={0} because another user tagged it."
                              .format(item_id))

        if item.hasFieldsExceptOf(user_login):
            raise err.AccessError("Cannot delete item id={0} because another user attached a field to it."
                              .format(item_id))

        data_ref = item.data_ref

        item.data_ref = None
        item.data_ref_id = None
        item.alive = False
        self._session.flush()
        #All bounded ItemTag and ItemField objects stays in database with the Item

        #If data_ref is not referenced by other Items, we delete it

        delete_data_ref = data_ref is not None

        #We should not delete DataRef if it is owned by another user
        if delete_data_ref and data_ref.user_login != user_login:
            delete_data_ref = False

        if delete_data_ref:
            another_item = self._session.query(db.Item).filter(db.Item.data_ref==data_ref).first()
            if another_item:
                delete_data_ref = False

        if delete_data_ref:
            is_file = (data_ref.type == db.DataRef.FILE)
            abs_path = os.path.join(self._repoBasePath, data_ref.url)

            self._session.delete(data_ref)
            self._session.flush()

            if is_file and delete_physical_file and os.path.exists(abs_path):
                os.remove(abs_path)

        self._session.commit()