σ
mάJ]c           @` s   d  Z  d d l m Z m Z m Z m Z d d l Z e j e  Z	 d d l
 m Z d d l m Z m Z d d l m Z m Z d
 Z d e f d	     YZ d S(   u9    Abstract request handler that handles bokeh-session-id

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   gen(   t   RequestHandlert	   HTTPError(   t   generate_session_idt   check_session_id_signatureu   SessionHandlert   SessionHandlerc           B` s2   e  Z d  Z d   Z d   Z e j d    Z RS(   uD    Implements a custom Tornado handler for document display page

    c         O` s:   | d |  _  | d |  _ t t |   j | | |  d  S(   Nu   application_contextu   bokeh_websocket_path(   t   application_contextt   bokeh_websocket_patht   superR	   t   __init__(   t   selft   tornado_appt   argst   kw(    (    sA   lib/python2.7/site-packages/bokeh/server/views/session_handler.pyR   4   s    c         O` s   d  S(   N(    (   R   R   R   (    (    sA   lib/python2.7/site-packages/bokeh/server/views/session_handler.pyt
   initialize:   s    c         c` sξ   |  j  d d d  } | d  k rv |  j j rQ t d |  j j d |  j j  } qΒ t j d  t	 d d d d	   nL t
 | d |  j j d |  j j sΒ t j d
 |  t	 d d d d   n  |  j j | |  j  V} t j |   d  S(   Nu   bokeh-session-idt   defaultt
   secret_keyt   signeduC   Server configured not to generate session IDs and none was providedt   status_codei  t   reasonu   No bokeh-session-id providedu$   Session id had invalid signature: %ru   Invalid session ID(   t   get_argumentt   Nonet   applicationt   generate_session_idsR   R   t   sign_sessionst   logt   debugR   R   t   errorR
   t   create_session_if_neededt   requestR   t   Return(   R   t
   session_idt   session(    (    sA   lib/python2.7/site-packages/bokeh/server/views/session_handler.pyt   get_session=   s    	(   t   __name__t
   __module__t   __doc__R   R   R   t	   coroutineR%   (    (    (    sA   lib/python2.7/site-packages/bokeh/server/views/session_handler.pyR	   0   s   		(   u   SessionHandler(   R(   t
   __future__R    R   R   R   t   loggingt	   getLoggerR&   R   t   tornadoR   t   tornado.webR   R   t   bokeh.util.session_idR   R   t   __all__R	   (    (    (    sA   lib/python2.7/site-packages/bokeh/server/views/session_handler.pyt   <module>	   s   "	