a
    ø£BeR  ã                   @   sZ   d Z ddlZddlmZ ddlmZ ddlmZ dZG dd	„ d	eƒZ	d
Z
de
 e	fgZdS )z-Tornado handlers for frontend config storage.é    N)Úweb)Ú
authorizedé   )Ú
APIHandlerÚconfigc                   @   sJ   e Zd ZdZeZejedd„ ƒƒZ	ejedd„ ƒƒZ
ejedd„ ƒƒZdS )	ÚConfigHandlerzA config API handler.c                 C   s(   |   dd¡ |  t | j |¡¡¡ dS )zGet config by section name.zContent-Typezapplication/jsonN)Z
set_headerÚfinishÚjsonÚdumpsÚconfig_managerÚget)ÚselfÚsection_name© r   új/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/jupyter_server/services/config/handlers.pyr      s    zConfigHandler.getc                 C   s$   |   ¡ }| j ||¡ |  d¡ dS )zSet a config section by name.éÌ   N)Úget_json_bodyr   ÚsetZ
set_status)r   r   Údatar   r   r   Úput   s    zConfigHandler.putc                 C   s*   |   ¡ }| j ||¡}|  t |¡¡ dS )z Update a config section by name.N)r   r   Úupdater   r	   r
   )r   r   Znew_dataÚsectionr   r   r   Úpatch#   s    zConfigHandler.patchN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚAUTH_RESOURCEZauth_resourcer   Úauthenticatedr   r   r   r   r   r   r   r   r      s   r   z(?P<section_name>\w+)z/api/config/%s)r   r	   Útornador   Zjupyter_server.authr   Zbase.handlersr   r   r   Zsection_name_regexZdefault_handlersr   r   r   r   Ú<module>   s   
ÿ