TransactionalTable - Интерфейс транзакционной таблицы ===================================================== .. currentmodule:: axioma.core.dp .. class:: TransactionalTable Абстрактный класс, представляющий транзакционную таблицу. Из редактируемой таблицы :class:`~axioma.core.dp.EditableTable` можно получить транзакционную, используя функцию :func:`~axioma.core.dp.wrap` Унаследован от: * :class:`~axioma.core.dp.EditableTable` Методы: .. method:: insert(cursor, description=str()) Вставить записи в таблицу :param cursor: итератор по записям :type cursor: :class:`~axioma.core.dp.Cursor` :param description: описание операции :type description: :class:`str` .. method:: insert(feature_list, description=str()) Вставить записи в таблицу :param feature_list: список записей :type feature_list: :class:`list` [:class:`~axioma.core.dp.Feature`] :param description: описание операции :type description: :class:`str` .. method:: remove(cursor, description=str()) Удалить записи из таблицы :param cursor: итератор по записям :type cursor: :class:`~axioma.core.dp.Cursor` :param description: описание операции :type description: :class:`str` .. method:: remove(feature_list, description=str()) Удалить записи из таблицы :param feature_list: список записей :type feature_list: :class:`list` [:class:`~axioma.core.dp.Feature`] :param description: описание операции :type description: :class:`str` .. method:: update(cursor, description=str()) Обновить записи в таблице :param cursor: итератор по записям :type cursor: :class:`~axioma.core.dp.Cursor` :param description: описание операции :type description: :class:`str` .. method:: update(feature_list, description=str()) Обновить записи в таблице :param feature_list: список записей :type feature_list: :class:`list` [:class:`~axioma.core.dp.Feature`] :param description: описание операции :type description: :class:`str` .. method:: commit() Внести все изменения в таблицу .. method:: restore() Отменить все изменения таблицы .. function:: wrap(edit_table) Обернуть редактируемую таблицу в транзакционную. Файл транзакции будет создан, если это возможно, в директории с данными редактируемой таблицы, иначе будет создан :any:`временный файл `. :param edit_table: редактируемая таблица :type edit_table: :class:`~axioma.core.dp.EditableTable` .. function:: wrap(edit_table, file_path) Обернуть редактируемую таблицу в транзакционную :param edit_table: редактируемая таблица :type edit_table: :class:`~axioma.core.dp.EditableTable` :param file_path: путь к файлу транзакции, который будет создан :type file_path: :class:`str` Пример использования: .. code-block:: python # Открываем таблицу table = open_file('world.tab') if table is not None: # Формируем данные для последующей вставки index_geometry = table.tableSchema().indexOf('object') index_style = table.tableSchema().indexOf('tr$$_rendition') new_feature = Feature.createFeature(table.tableSchema()) poly = QPolygonF(); v = 1000000 poly << QPointF(-v, -v) << QPointF(-v, v) << QPointF(v, v) << QPointF(v, -v) << QPointF(-v, -v) polygon = Polygon(table.coordSystem(), poly) new_feature.setAttribute(index_geometry, polygon) new_feature.setModified(index_geometry, True) style = MapBasicStyle().styleFromString('Pen (1,2,0) Brush (2, 65280, 16777215)') new_feature.setAttribute(index_style, style) new_feature.setModified(index_style, True) # Можно произвести дополнительную проверку, создана ли для данной таблицы обертка. if isinstance(table, TransactionalTable): # Если да, то сразу можно производить изменения table.insert([new_feature]) table.commit() else: # Если нет, то создаем ее посредством wrap ttable = wrap(table) # Вставляем новую запись ttable.insert([new_feature]) # Сохраняем изменения ttable.commit()