Files
pillar/pillar/api/nodes/custom/__init__.py
Francesco Siddi 2c5dc34ea2 Introducing Pillar Framework
Refactor of pillar-server and pillar-web into a single python package. This
simplifies the overall architecture of pillar applications.

Special thanks @sybren and @venomgfx
2016-08-19 09:19:06 +02:00

25 lines
712 B
Python

import logging
log = logging.getLogger(__name__)
patch_handlers = {} # mapping from node type to callable.
def register_patch_handler(node_type):
"""Decorator, registers the decorated function as patch handler for the given node type."""
def wrapper(func):
if node_type in patch_handlers:
raise ValueError('Node type %r already handled by %r' %
(node_type, patch_handlers[node_type]))
log.debug('Registering %s as PATCH handler for node type %r',
func, node_type)
patch_handlers[node_type] = func
return func
return wrapper
# Import sub-modules so they can register themselves.
from . import comment