σ
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 d Z d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d S(   uf    Provide classes to represent callback code that can be associate with
Bokeh Documents and Sessions.

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsNi   (   t   make_id(   t   _CallbackGroupu   NextTickCallbacku   PeriodicCallbacku   SessionCallbacku   TimeoutCallbackt   SessionCallbackc           B` sA   e  Z d  Z d d  Z e d    Z e d    Z d   Z RS(   uZ    A base class for callback objects associated with Bokeh Documents
    and Sessions.

    c         C` s4   | d k r t   n | |  _ | |  _ | |  _ d S(   u   

         Args:
            document (Document) :

            callback (callable) :

            id (str, optional) :

        N(   t   NoneR   t   _idt	   _documentt	   _callback(   t   selft   documentt   callbackt   id(    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyt   __init__4   s    	c         C` s   |  j  S(   u(    A unique ID for this callback

        (   R   (   R   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   C   s    c         C` s   |  j  S(   u1    The callable that this callback wraps.

        (   R
   (   R   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   J   s    c         C` s   t  d   d S(   u4    Dev API used to wrap the callback with decorators. u   _copy_with_changed_callbackN(   t   NotImplementedError(   R   t   new_callback(    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyt   _copy_with_changed_callbackQ   s    N(	   t   __name__t
   __module__t   __doc__R   R   t   propertyR   R   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   /   s
   t   NextTickCallbackc           B` s#   e  Z d  Z d d  Z d   Z RS(   uE    Represent a callback to execute on the next ``IOLoop`` "tick".

    c         C` s    t  t |   j | | |  d S(   u   

         Args:
            document (Document) :

            callback (callable) :

            id (str, optional) :

        N(   t   superR   R   (   R   R   R   R   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   ]   s    c         C` s   t  |  j | |  j  S(   u4    Dev API used to wrap the callback with decorators. (   R   R	   R   (   R   R   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   j   s    N(   R   R   R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   Y   s   t   PeriodicCallbackc           B` s2   e  Z d  Z d d  Z e d    Z d   Z RS(   up    Represent a callback to execute periodically on the ``IOLoop`` at a
    specified periodic time interval.

    c         C` s)   t  t |   j | | |  | |  _ d S(   u   

        Args:
            document (Document) :

            callback (callable) :

            period (int) :

            id (str, optional) :

        N(   R   R   R   t   _period(   R   R   R   t   periodR   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   s   s    c         C` s   |  j  S(   uc    The period time (in milliseconds) that this callback should
        repeat execution at.

        (   R   (   R   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR      s    c         C` s   t  |  j | |  j |  j  S(   u4    Dev API used to wrap the callback with decorators. (   R   R	   R   R   (   R   R   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR      s    N(   R   R   R   R   R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   n   s   t   TimeoutCallbackc           B` s2   e  Z d  Z d d  Z e d    Z d   Z RS(   ui    Represent a callback to execute once on the ``IOLoop`` after a specified
    time interval passes.

    c         C` s)   t  t |   j | | |  | |  _ d S(   u   

        Args:
            document (Document) :

            callback (callable) :

            timeout (int) :

            id (str, optional) :

        N(   R   R   R   t   _timeout(   R   R   R   t   timeoutR   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR      s    c         C` s   |  j  S(   uL    The timeout (in milliseconds) that the callback should run after.

        (   R   (   R   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   €   s    c         C` s   t  |  j | |  j |  j  S(   u4    Dev API used to wrap the callback with decorators. (   R   R	   R   R   (   R   R   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   «   s    N(   R   R   R   R   R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR      s   t   _DocumentCallbackGroupc           B` s>   e  Z d  Z d d  Z d   Z d   Z d   Z d   Z RS(   u   

    c         C` s   t  |  |  _ d S(   u
   

        N(   R   t   _group(   R   t   io_loop(    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   ·   s    c         C` s   |  j  j   d S(   u
   

        N(   R    t   remove_all_callbacks(   R   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR"   ½   s    c         C` s"   x | D] } |  j  |  q Wd S(   u
   

        N(   t   add_session_callback(   R   t	   callbackst   cb(    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyt   add_session_callbacksΓ   s    c         C` s€   t  | t  r1 |  j j | j | j | j  no t  | t  rb |  j j | j | j	 | j  n> t  | t
  r |  j j | j | j  n t d | j   d S(   u
   

        uV   Expected callback of type PeriodicCallback, TimeoutCallback, NextTickCallback, got: %sN(   t
   isinstanceR   R    t   add_periodic_callbackR   R   R   R   t   add_timeout_callbackR   R   t   add_next_tick_callbackt
   ValueError(   R   t   callback_obj(    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR#   Κ   s    ""c         C` s   ys t  | t  r( |  j j | j  nJ t  | t  rM |  j j | j  n% t  | t  rr |  j j | j  n  Wn t	 k
 r n Xd S(   u
   

        N(
   R'   R   R    t   remove_periodic_callbackR   R   t   remove_timeout_callbackR   t   remove_next_tick_callbackR+   (   R   R,   (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyt   remove_session_callbackΧ   s    	N(	   R   R   R   R   R   R"   R&   R#   R0   (    (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyR   ³   s   			(   u   NextTickCallbacku   PeriodicCallbacku   SessionCallbacku   TimeoutCallback(   R   t
   __future__R    R   R   R   t   loggingt	   getLoggerR   t   logt   util.serializationR   t   util.tornadoR   t   __all__t   objectR   R   R   R   R   (    (    (    s5   lib/python2.7/site-packages/bokeh/server/callbacks.pyt   <module>
   s   "   *!$