• S sverchok
  • Информация о проекте
    • Информация о проекте
    • Активность
    • Метки
    • Участники
  • Репозиторий
    • Репозиторий
    • Файлы
    • Коммиты
    • Ветки
    • Теги
    • Участники
    • Диаграмма
    • Сравнение
  • Задачи 148
    • Задачи 148
    • Список
    • Доски
    • Спринты
  • Запросы на слияние 21
    • Запросы на слияние 21
  • CI/CD
    • CI/CD
    • Конвейеры
    • Задания
    • Расписания
  • Развертывания
    • Развертывания
    • Окружения
    • Релизы
  • Пакеты и реестры
    • Пакеты и реестры
    • Реестр пакетов
    • Реестр контейнеров
  • Мониторинг
    • Мониторинг
    • Инциденты
  • Аналитика
    • Аналитика
    • Поток ценности
    • CI/CD
    • Репозиторий
  • Wiki
    • Wiki
  • Сниппеты
    • Сниппеты
  • Активность
  • Диаграмма
  • Создать новую задачу
  • Задания
  • Коммиты
  • Доски с задачами
Свернуть панель
  • nikitronn
  • sverchok
  • Запросы на слияние
  • !2692

B28 updatefunc decorator

  • Ревью изменений

  • Скачать
  • Почтовые патчи
  • Простое отличие
Слиты nikitronn запросил слияние b28_updatefunc_decorator в b28_prelease_master Ноя 25, 2019
  • Обзор 8
  • Коммиты 11
  • Конвейеры 0
  • Изменения 8

Created by: zeffii

new decorator for updateNode wrappers..

implementation details

this is only a preliminary implementation, because it might be useful to include a way to end the update function early, and not ultimately process_node.

# use as a decorator
def throttled(func):
    """
    When a node has changed, like a mode-change leading to a socket change (remove, new)
    Blender will trigger nodetree.update. We want to ignore this trigger-event, and we do so by
    - first throttling the update system. 
    - then We execute the code that makes changes to the node/nodetree
    - then we end the throttle-state
    - we are then ready to process

    """
    def wrapper_update(self, context):
        with self.sv_throttle_tree_update():
            func(self, context)
        self.process_node(context)

    return wrapper_update

usage


from sverchok.node_tree import SverchCustomTreeNode, throttled

class SvYourNode(...):

    ...

    @throttled
    def mode_update_wrapper(self, context):

        # your nodetree update triggering stuff here 
        #             1) changes to sockets
        #             2) changes to links
        # the decorator calls   self.process_node(context)    for you

    mode_direction: bpy.props.EnumProperty(......update=mode_update_wrapper)

Why ?

this means that we can abstract away the task of throttleing, and also assume that the node tree will be udpated at the end.

issues..

  1. i'm not sure on the name, but the implementation seems sound.
  2. maybe later after testing the implementation and encountering special cases, we might consider adding the ability to pass an 'exit_function`..
Ответственный
Назначить
Проверяющие
Запросить ревью
Оценка трудозатрат
Исходная ветка: b28_updatefunc_decorator