Ñò
xĵKc        
   @   sÛ   d  Z  d d k l Z d d k l Z d d k l Z l Z l Z d d k	 l
 Z
 l Z l Z l Z l Z d d k l Z l Z d d k l Z d d k l Z l Z e i e i e  d	  Z d
 e f d     YZ d S(   s  
    simplewiki.application
    ~~~~~~~~~~~~~~~~~~~~~~

    This module implements the wiki WSGI application which dispatches
    requests to specific wiki pages and actions.


    :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details.
    :license: BSD.
i˙˙˙˙(   t   path(   t   create_engine(   t   ClosingIteratort   SharedDataMiddlewaret   redirect(   t   Requestt   Responset   localt   local_managert   href(   t   sessiont   metadata(   t   actions(   t   pagest   page_not_foundt   sharedt
   SimpleWikic           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s'   
    Our central WSGI application.
    c         C   sD   t  |  |  _ t |  i h t d 6 |  _ t i |  i  |  _ d  S(   Ns   /_shared(   R   t   database_engineR   t   dispatch_requestt   SHARED_DATAt	   _dispatchR   t   make_middleware(   t   selft   database_uri(    (    sM   /Users/mitsuhiko/Development/werkzeug-main/examples/simplewiki/application.pyt   __init__   s    c         C   s   t  i d |  i  d S(   s5   Called from the management script to generate the db.t   bindN(   R   t
   create_allR   (   R   (    (    sM   /Users/mitsuhiko/Development/werkzeug-main/examples/simplewiki/application.pyt   init_database,   s    c         C   s   |  t  _ d S(   s   
        Useful for the shell.  Binds the application to the current active
        context.  It's automatically called by the shell command.
        N(   R   t   application(   R   (    (    sM   /Users/mitsuhiko/Development/werkzeug-main/examples/simplewiki/application.pyt   bind_to_context0   s    c   
      C   sJ  |  i    t |  } | i    | i i d  p d } d i g  } | i i d  i   D] } | o | | q\ q\ ~  } | p t t	 d   } n | i
 d  o< | d t j o t | |  } q1t | d |  } nI t t d | d	  }	 |	 d	 j o t i | |  } n |	 | |  } t | | |  t i  S(
   s   Dispatch an incoming request.t   actiont   showu   _t   /t	   Main_Pages   Special:i   t   on_N(   R   R   t   argst   gett   joinR    t   stript   splitR   R	   t
   startswithR   R   t   getattrR   t   Nonet   missing_actionR   R
   t   remove(
   R   t   environt   start_responset   requestt   action_namet   _[1]t   xt	   page_namet   responseR   (    (    sM   /Users/mitsuhiko/Development/werkzeug-main/examples/simplewiki/application.pyR   7   s$    

)c         C   s   |  i  | |  S(   s:   Just forward a WSGI call to the first internal middleware.(   R   (   R   R-   R.   (    (    sM   /Users/mitsuhiko/Development/werkzeug-main/examples/simplewiki/application.pyt   __call___   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R5   (    (    (    sM   /Users/mitsuhiko/Development/werkzeug-main/examples/simplewiki/application.pyR      s   				(N(   R8   t   osR    t
   sqlalchemyR   t   werkzeugR   R   R   t   simplewiki.utilsR   R   R   R   R	   t   simplewiki.databaseR
   R   t
   simplewikiR   t   simplewiki.specialpagesR   R   R%   t   dirnamet   __file__R   t   objectR   (    (    (    sM   /Users/mitsuhiko/Development/werkzeug-main/examples/simplewiki/application.pyt   <module>   s   (