
ɷcc           @  s  d  Z  d d l m Z d d l Z d Z d Z d Z d   Z d   Z e	 d	 k rb e e j
  n  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d
 l m Z d d l m Z  m Z m! Z! d d l m" Z" d d l# m$ Z$ m% Z% d d l& m' Z' y d d l( m) Z* m+ Z, Wn' e- k
 rd d l. m) Z* m+ Z, n Xe j/ Z0 e0 j1 d k Z2 e2 rd d l3 j4 Z5 d d l6 Z7 d d l8 m9 Z9 m: Z; d d l8 m< Z< m= Z> m? Z@ e jA e@ d d Z@ d d lB mC ZC mD ZD mE ZE d d lF mG ZH d d l mI ZJ d d lK ZK d d lL mM ZM d d lN ZN d d lO mP ZP d   ZQ eR ZS eR ZT d   ZU d   ZV eW ZX d   ZY n d d l5 Z5 d d l7 Z7 d d lZ m9 Z9 m: Z; d d l[ m< Z< m= Z> m? Z@ d d l\ mC ZC mD ZD mE ZE d d l mX ZX d d l] ZK d d l^ mJ ZJ d d  l_ m_ ZM d d l` ZN d d la mG ZH d d! lO mQ ZQ eT ZT e, ZU eb d" d# d$  d Ud% d&  Zc d% d' d(  Zd e2 r
ed n ec Ze d)   Zf d*   Zg d+   Zh d,   Zi d- ej f d.     YZk d/ ej f d0     YZl d1 ej f d2     YZm d3 en f d4     YZo d5 eo f d6     YZp d7 eo f d8     YZq d9 ep f d:     YZr d; ep f d<     YZs d= ep f d>     YZt d?   Zu d@ ej f dA     YZv dB ej f dC     YZw dD ej f dE     YZx dF ej f dG     YZy dH   Zz dI   Z{ dJ ej f dK     YZ| dL ej f dM     YZ} dN   Z~ dO ey f dP     YZ dQ e} f dR     YZ ey Z e} Z dS e eo f dT     YZ dU e f dV     YZ dW eo f dX     YZ dY ej f dZ     YZ d[ ej f d\     YZ d] ej f d^     YZ d_ eH f d`     YZ da e f db     YZ dc e f dd     YZ de eH f df     YZ ej   Z dg e f dh     YZ di e f dj     YZ dk ej f dl     YZ dm ej f dn     YZ do ej f dp     YZ dq ej f dr     YZ ds dt du  Z e dv  Z dw dw dx  Z e e dy e e dz  Z e d{  Z d|   Z d}   Z d~   Z d d  Z e jb d  j Z d   Z d   Z d   Z e d  Z e d  Z d   Z d   Z d   Z d   Z d d  Z d d d  Z d   Z e d  Z e d  Z e d  Z e d  Z e d  Z e d  Z e d  Z e d  Z e d  Z e d  Z e d  Z e d  Z d ej f d     YZ 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 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 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 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 e f d     YZ i e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6e d 6Z d   Z d   Z e Z e d d d d e e e e e d 
 Z d e j f d     YZ d eo f d     YZ d ej f d     YZ 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 ej f d     YZ d   Z e jA e d e Z e jA e d e Z e jA e d e Z d   Z e jA e d e Z e jA e d e Z e jA e d e Z d d g Z i  Z e a e a e5 j j   Z d e d <d e d <d e d <d e d <de d<de d<e d  e j   D  Z de	 Z e   Z e   Z e j   Z e   Z Z Z e e	 d	 k rdn e	 dd	 j Z d
  Z e	 d	 k re e j
  n  d S(  s  
Bottle is a fast and simple micro-framework for small web applications. It
offers request dispatching (Routes) with URL parameter support, templates,
a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and
template engines - all in a single file and with no dependencies other than the
Python Standard Library.

Homepage and documentation: http://bottlepy.org/

Copyright (c) 2009-2018, Marcel Hellkamp.
License: MIT (see LICENSE for details)
i(   t   print_functionNs   Marcel Hellkamps   0.13-devt   MITc      	   C  s0  d d l  m } | d |  d d d  } | j } | d d d	 d
 d | d d d d d
 d | d d d d d
 d | d d d d d
 d | d d d d d d d
 d | d d d d d d  d
 d! | d" d d	 d
 d# | d$ d d	 d
 d% | d& d
 d' d( d) | j |  d*  } | | f S(+   Ni(   t   ArgumentParsert   progi    t   usages%   %(prog)s [options] package.module:apps	   --versiont   actiont
   store_truet   helps   show version number.s   -bs   --bindt   metavart   ADDRESSs   bind socket to ADDRESS.s   -ss   --servert   defaultt   wsgirefs   use SERVER as backend.s   -ps   --plugint   appends   install additional plugin/s.s   -cs   --conft   FILEs   load config values from FILE.s   -Cs   --params
   NAME=VALUEs   override config values.s   --debugs   start server in debug mode.s   --reloads   auto-reload on file changes.t   apps   WSGI app entry point.t   nargst   ?i   (   t   argparseR   t   add_argumentt
   parse_args(   t   argsR   t   parsert   optt   cli_args(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   _cli_parse   s     	c         C  s   t  |   \ } } | } | j r} | j j d  rO d d  l } | j j   q} | j j d  r} d d  l } | j   q} n  d  S(   Nt   geventit   eventlet(   R   t   servert
   startswitht   gevent.monkeyt   monkeyt	   patch_allR   t   monkey_patch(   R   t   parsed_argst   _t   optsR   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   _cli_patch5   s    	t   __main__(   t   FunctionType(   t   datet   datetimet	   timedelta(   t   NamedTemporaryFile(   t
   format_exct	   print_exc(   t	   normalize(   t   dumpst   loadsi   (   t   urljoint   SplitResult(   t	   urlencodet   quotet   unquotet   encodingt   latin1(   t   SimpleCookiet   Morselt   CookieError(   t   MutableMapping(   t
   ModuleType(   t   BytesIO(   t   getfullargspecc         C  sE   t  |   } t | d  t | j  } | | d | d | d f S(   Ni    i   i   i   (   R=   t   makelistt
   kwonlyargs(   t   funct   spect   kwargs(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   getargspeci   s    c         C  s   t  t |    S(   N(   t   json_ldst   touni(   t   s(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   <lambda>p   t    c         C  s   t  |  d  S(   Nt   __call__(   t   hasattr(   t   x(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   q   RH   c          G  s%   |  d |  d  j  |  d   d  S(   Ni    i   i   (   t   with_traceback(   t   a(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _raiset   s    (   t   imap(   t
   new_module(   t   StringIO(   RC   s&   def _raise(*a): raise a[0], a[1], a[2]s   <py3fix>t   exect   utf8c         C  s6   t  |  t  r |  j |  S|  d  k r, d St |   S(   NRH   (   t
   isinstancet   unicodet   encodet   Nonet   bytes(   RF   t   enc(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   tob   s    t   strictc         C  s;   t  |  t  r |  j | |  St |  d  k r4 d n |   S(   NRH   (   RT   RX   t   decodeRU   RW   (   RF   RY   t   err(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRE      s    c          G  s5   y t  d t j |   Wn t t f k
 r0 n Xd  S(   Nt   file(   t   printt   syst   stderrt   IOErrort   AttributeError(   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _stderr   s    c         O  s2   y t  j |  | | |  Wn t k
 r- n Xd  S(   N(   t	   functoolst   update_wrapperRc   (   t   wrappert   wrappedRM   t   ka(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRf      s    c         C  sQ   d |  | | | f } t  d k r1 t |   n  t j | t d d t |  S(   NsZ   Warning: Use of deprecated feature or API. (Deprecated in Bottle-%d.%d)
Cause: %s
Fix: %s
R[   t
   stackleveli   (   t   DEBUGt   DeprecationWarningt   warningst   warn(   t   majort   minort   causet   fixt   text(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   depr   s    c         C  s:   t  |  t t t t f  r% t |   S|  r2 |  g Sg  Sd  S(   N(   RT   t   tuplet   listt   sett   dict(   t   data(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR>      s
    
t   DictPropertyc           B  sA   e  Z d  Z d e d  Z d   Z d   Z d   Z d   Z	 RS(   s=    Property that maps to a key in a local dict-like attribute. c         C  s!   | | | |  _  |  _ |  _ d  S(   N(   t   attrt   keyt	   read_only(   t   selfR{   R|   R}   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __init__   s    c         C  s9   t  j |  | d g  | |  j p( | j |  _ |  _ |  S(   Nt   updated(   Re   Rf   R|   t   __name__t   getter(   R~   R@   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRI      s    c         C  sV   | d  k r |  S|  j t | |  j  } } | | k rN |  j |  | | <n  | | S(   N(   RW   R|   t   getattrR{   R   (   R~   t   objt   clsR|   t   storage(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __get__   s      c         C  s5   |  j  r t d   n  | t | |  j  |  j <d  S(   Ns   Read-Only property.(   R}   Rc   R   R{   R|   (   R~   R   t   value(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __set__   s    	 c         C  s2   |  j  r t d   n  t | |  j  |  j =d  S(   Ns   Read-Only property.(   R}   Rc   R   R{   R|   (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   __delete__   s    	 N(
   R   t
   __module__t   __doc__RW   t   FalseR   RI   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRz      s   			t   cached_propertyc           B  s    e  Z d  Z d   Z d   Z RS(   s    A property that is only computed once per instance and then replaces
        itself with an ordinary attribute. Deleting the attribute resets the
        property. c         C  s   t  |  |  | |  _ d  S(   N(   Rf   R@   (   R~   R@   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR      s    c         C  s4   | d  k r |  S|  j |  } | j |  j j <| S(   N(   RW   R@   t   __dict__R   (   R~   R   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR      s      (   R   R   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR      s   	t   lazy_attributec           B  s    e  Z d  Z d   Z d   Z RS(   s4    A property that caches itself to the class object. c         C  s#   t  j |  | d g  | |  _ d  S(   NR   (   Re   Rf   R   (   R~   R@   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR      s    c         C  s&   |  j  |  } t | |  j |  | S(   N(   R   t   setattrR   (   R~   R   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR      s    (   R   R   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR      s   	t   BottleExceptionc           B  s   e  Z d  Z RS(   s-    A base class for exceptions used by bottle. (   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR      s   t
   RouteErrorc           B  s   e  Z d  Z RS(   s9    This is a base class for all routing related exceptions (   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s   t
   RouteResetc           B  s   e  Z d  Z RS(   sf    If raised by a plugin or request handler, the route is reset and all
        plugins are re-applied. (   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s   t   RouterUnknownModeErrorc           B  s   e  Z RS(    (   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   
  s   t   RouteSyntaxErrorc           B  s   e  Z d  Z RS(   s@    The route parser found something not supported by this router. (   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s   t   RouteBuildErrorc           B  s   e  Z d  Z RS(   s    The route could not be built. (   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s   c         C  s&   d |  k r |  St  j d d   |   S(   s^    Turn all capturing groups in a regular expression pattern into
        non-capturing groups. t   (s   (\\*)(\(\?P<[^>]+>|\((?!\?))c         S  s7   t  |  j d   d r& |  j d  S|  j d  d S(   Ni   i   i    s   (?:(   t   lent   group(   t   m(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG     s    (   t   ret   sub(   t   p(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _re_flatten  s    t   Routerc           B  st   e  Z d  Z d Z d Z d Z e d  Z d   Z e	 j
 d  Z d   Z d d  Z d	   Z d
   Z d   Z RS(   sA   A Router is an ordered collection of route->target pairs. It is used to
        efficiently match WSGI requests against a number of routes and return
        the first target that satisfies the request. The target may be anything,
        usually a string, ID or callable object. A route consists of a path-rule
        and a HTTP method.

        The path-rule is either a static path (e.g. `/contact`) or a dynamic
        path that contains wildcards (e.g. `/wiki/<page>`). The wildcard syntax
        and details on the matching order are described in docs:`routing`.
    s   [^/]+R   ic   c           sz   g    _  i    _ i    _ i    _ i    _ i    _ |   _ i   f d   d 6d   d 6d   d 6d   d 6  _ d  S(	   Nc           s   t  |  p   j  d  d  f S(   N(   R   t   default_patternRW   (   t   conf(   R~   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   =  s   R   c         S  s   d t  d   f S(   Ns   -?\d+c         S  s   t  t |    S(   N(   t   strt   int(   RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   ?  RH   (   R   (   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   ?  RH   R   c         S  s   d t  d   f S(   Ns   -?[\d.]+c         S  s   t  t |    S(   N(   R   t   float(   RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   @  RH   (   R   (   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   @  RH   R   c         S  s   d S(   Ns   .+?(   s   .+?NN(   RW   (   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   A  RH   t   path(   t   rulest   _groupst   buildert   statict   dyna_routest   dyna_regexest   strict_ordert   filters(   R~   R[   (    (   R~   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   3  s    							

c         C  s   | |  j  | <d S(   s    Add a filter. The provided function is called with the configuration
        string as parameter and must return a (regexp, to_python, to_url) tuple.
        The first element is a string, the last two are callables or None. N(   R   (   R~   t   nameR@   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   add_filterD  s    s   (\\*)(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)|(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)(?::((?:\\.|[^\\>])+)?)?)?>))c   	      c  se  d \ } } x!|  j  j |  D]} | | | | j   !7} | j   } | d d  k	 rn t d d d d  n  t | d  d r | | j d  t | d  7} | j   } q n  | r | d  d  f Vn  | d d  k r | d d !n
 | d	 d !\ } } } | | pd
 | pd  f V| j   d } } q W| t |  k sH| ra| | | d  d  f Vn  d  S(   Ni    RH   i   i   s   Use of old route syntax.s&   Use <name> instead of :name in routes.i   i   i   R
   (   i    RH   (	   t   rule_syntaxt   finditert   startt   groupsRW   Rt   R   R   t   end(	   R~   t   rulet   offsett   prefixt   matcht   gR   t   filtrR   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _itertokensO  s$    
!3c           s  d } g  } d } g    g  } t  }	 x|  j |  D]\ }
 } } | rt }	 | d k rg |  j } n  |  j | |  \ } } } |
 s | d | 7} d | }
 | d 7} n! | d |
 | f 7} | j |
  | r   j |
 | f  n  | j |
 | p t f  q4 |
 r4 | t j |
  7} | j d |
 f  q4 q4 W| |  j
 | <| r]| |  j
 | <n  |	 r|  j r|  j j | i   | d f |  j | |  j |  <d Sy  t j d	 |  } | j  Wn, t j k
 r} t d
 | | f   n X  r   f d   } n! | j r) f d   } n d } t |  } | | | | f } | | f |  j k rt rd } t j | | | f t  n  | |  j | |  j | | f <n@ |  j j | g   j |  t |  j |  d |  j | | f <|  j |  d S(   s<    Add a new rule or replace the target for an existing rule. i    RH   R
   s   (?:%s)s   anon%di   s
   (?P<%s>%s)Ns   ^(%s)$s   Could not add Route: %s (%s)c           sh    |   j    } xO   D]G \ } } y | | |  | | <Wq t k
 r_ t d d   q Xq W| S(   Ni  s   Path has wrong format.(   t	   groupdictt
   ValueErrort	   HTTPError(   R   t   url_argsR   t   wildcard_filter(   R   t   re_match(    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   getargs  s    c           s     |   j    S(   N(   R   (   R   (   R   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    s3   Route <%s %s> overwrites a previously defined route(   t   TrueR   R   t   default_filterR   R   R   R   t   escapeRW   R   R   R   t
   setdefaultt   buildt   compileR   t   errorR   t
   groupindexR   R   Rk   Rm   Rn   t   RuntimeWarningR   R   t   _compile(   R~   R   t   methodt   targetR   t   anonst   keyst   patternR   t	   is_staticR|   t   modeR   t   maskt	   in_filtert
   out_filtert
   re_patternt   eR   t   flatpatt
   whole_rulet   msg(    (   R   R   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   addc  sf     
   	!$c         C  s   |  j  | } g  } |  j | <|  j } x t d t |  |  D] } | | | | !} d   | D } d j d   | D  } t j |  j } g  | D] \ } } }	 }
 |	 |
 f ^ q } | j	 | | f  q@ Wd  S(   Ni    c         s  s!   |  ] \ } } } } | Vq d  S(   N(    (   t   .0R"   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>  s    t   |c         s  s   |  ] } d  | Vq d S(   s   (^%s$)N(    (   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>  s    (
   R   R   t   _MAX_GROUPS_PER_PATTERNt   rangeR   t   joinR   R   R   R   (   R~   R   t	   all_rulest
   comborulest	   maxgroupsRK   t   somet   combinedR"   R   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    	+c         O  s   |  j  j |  } | s* t d |   n  y x( t |  D] \ } } | | d | <q: Wd j g  | D]- \ } } | r | | j |   n | ^ qe  }	 | s |	 S|	 d t |  SWn* t k
 r }
 t d |
 j d   n Xd S(   s2    Build an URL by filling the wildcards in a rule. s   No route with that name.s   anon%dRH   R   s   Missing URL argument: %ri    N(	   R   t   getR   t	   enumerateR   t   popR2   t   KeyErrorR   (   R~   t   _nameR   t   queryR   t   iR   t   nt   ft   urlt   E(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    C c         C  s'  | d j    } | d p d } | d k r2 d n d | d f } x | D] } | |  j k r | |  j | k r |  j | | \ } } | | r | |  n i  f S| |  j k rH xc |  j | D]Q \ } }	 | |  }
 |
 r |	 |
 j d \ } } | | r
| |  n i  f Sq WqH qH Wt g   } t |  } x> t |  j  | D]) } | |  j | k rH| j |  qHqHWx_ t |  j  | | D]F } x= |  j | D]. \ } }	 | |  }
 |
 r| j |  qqWqW| r
d	 j t |   } t d
 d d |  n  t d d t	 |    d S(   sD    Return a (target, url_args) tuple or raise HTTPError(400/404/405). t   REQUEST_METHODt	   PATH_INFOt   /t   HEADt   PROXYt   GETt   ANYi   t   ,i  s   Method not allowed.t   Allowi  s   Not found: N(   R   R   R   R   (
   t   upperR   R   t	   lastindexRw   R   R   t   sortedR   t   repr(   R~   t   environt   verbR   t   methodsR   R   R   R   R   R   t   allowedt   nocheckt   allow_header(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s6    !"'N(   R   R   R   R   R   R   R   R   R   R   R   R   R   RW   R   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR      s   
		I		t   Routec           B  sz   e  Z d  Z d d d d  Z e d    Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d d	  Z d
   Z RS(   s    This class wraps a route callback along with route specific metadata and
        configuration and applies Plugins on demand. It is also responsible for
        turning an URL path rule into a regular expression usable by the Router.
    c   	      K  sw   | |  _  | |  _ | |  _ | |  _ | p- d  |  _ | p< g  |  _ | pK g  |  _ | j j	   |  _ |  j j
 |  d  S(   N(   R   R   R   t   callbackRW   R   t   pluginst   skiplistt   configt   _make_overlayt	   load_dict(	   R~   R   R   R   R  R   R  R	  R
  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    				c         C  s
   |  j    S(   s    The route callback with all plugins applied. This property is
            created on demand and then cached to speed up subsequent requests.(   t   _make_callback(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   call  s    c         C  s   |  j  j d d  d S(   sk    Forget any cached values. The next time :attr:`call` is accessed,
            all plugins are re-applied. R  N(   R   R   RW   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   reset  s    c         C  s   |  j  d S(   s:    Do all on-demand work immediately (useful for debugging).N(   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   prepare  s    c         c  s   t    } x t |  j j |  j  D] } t |  j k r< Pn  t | d t  } | ru | |  j k s# | | k ru q# n  | |  j k s# t |  |  j k r q# n  | r | j	 |  n  | Vq# Wd S(   s)    Yield all Plugins affecting this route. R   N(
   Rw   t   reversedR   R  R   R	  R   R   t   typeR   (   R~   t   uniqueR   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   all_plugins  s    	  ! $  c         C  s   |  j  } x |  j   D]w } y4 t | d  rC | j | |   } n | |  } Wn t k
 rj |  j   SX| |  j  k	 r t | |  j   q q W| S(   Nt   apply(   R  R  RJ   R  R   R  Rf   (   R~   R  t   plugin(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  "  s    	c         C  s   |  j  } t | t r d n d |  } t r3 d n d } x~ t | |  r t | |  r t | |  } | d j } t | t  s< t d   t d   |   } t	 |  d } q< q< W| S(   sq    Return the callback. If the callback is a decorated function, try to
            recover the original function. t   __func__t   im_funct   __closure__t   func_closurei    c         S  s   t  |  t  S(   N(   RT   R&   (   RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   =  RH   c         S  s   |  j  S(   N(   t   cell_contents(   RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   >  RH   (
   R  R   t   py3kRJ   R  RT   R&   t   filtert   mapRv   (   R~   R@   t   closure_attrt
   attributes(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   get_undecorated_callback0  s    	!	c         C  s   t  |  j    d S(   s    Return a list of argument names the callback (most likely) accepts
            as keyword arguments. If the callback is a decorated function, try
            to recover the original function before inspection. i    (   RC   R!  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   get_callback_argsB  s    c         C  s&   t  d d d d  |  j j | |  S(   sp    Lookup a config field and return its value, first checking the
            route.config, then route.app.config.i    i   s!   Route.get_config() is deprecated.ss   The Route.config property already includes values from the application config for missing keys. Access it directly.(   Rt   R
  R   (   R~   R|   R
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   get_configH  s    c         C  s,   |  j    } d |  j |  j | j | j f S(   Ns   <%s %s -> %s:%s>(   R!  R   R   R   R   (   R~   t   cb(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __repr__P  s    N(   R   R   R   RW   R   R   R  R  R  R  R  R!  R"  R#  R%  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   						t   Bottlec           B  s  e  Z d  Z e d    Z d   Z e d d  Z d. Z d h Z	 e
 d    Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d/ d  Z d   Z d   Z d   Z d   Z d   Z d/ d d/ d/ d/ d/ d  Z d/ d d  Z d/ d d  Z d/ d d  Z  d/ d  d!  Z! d/ d" d#  Z" d$ d/ d%  Z# d&   Z$ d'   Z% d/ d(  Z& d)   Z' d*   Z( d+   Z) d,   Z* d-   Z+ RS(0   s^   Each Bottle object represents a single, distinct web application and
        consists of routes, callbacks, plugins, resources and configuration.
        Instances are callable WSGI applications.

        :param catchall: If true (default), handle all exceptions. Turn off to
                         let debugging middleware handle exceptions.
    c         C  s    t    } | j d d t  | S(   Nt   catchallt   validate(   t
   ConfigDictt   meta_sett   bool(   R   t   cfg(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _global_configb  s    	c         K  s  |  j  j   |  _ |  j j t j |  j d   |  j j i t d 6 | j	 d  t
 k r t d d d d  t
 |  j d <n  | j	 d  t
 k r t d d d d	  t |  j d
 <n  g  |  _ t   |  _ g  |  _ t   |  _ i  |  _ g  |  _ |  j t    |  j t    d  S(   NR
  R'  i    i   s"   Bottle(catchall) keyword argument.sb   The 'catchall' setting is now part of the app configuration. Fix: `app.config['catchall'] = False`t   autojsons"   Bottle(autojson) keyword argument.se   The 'autojson' setting is now part of the app configuration. Fix: `app.config['json.enable'] = False`s   json.disable(   R-  R  R
  t   _add_change_listenerRe   t   partialt   trigger_hookt   updateR   R   R   Rt   t   _mountst   ResourceManagert	   resourcest   routesR   t   routert   error_handlerR  t   installt
   JSONPlugint   TemplatePlugin(   R~   RB   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   h  s*    					R
  R'  t   before_requestt   after_requestt	   app_resetc         C  s   t  d   |  j D  S(   Nc         s  s   |  ] } | g  f Vq d  S(   N(    (   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>  s    (   Rx   t   _Bottle__hook_names(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _hooks  s    c         C  sA   | |  j  k r) |  j | j d |  n |  j | j |  d S(   s   Attach a callback to a hook. Three hooks are currently implemented:

            before_request
                Executed once before each request. The request context is
                available, but no routing has happened yet.
            after_request
                Executed once after each request regardless of its outcome.
            app_reset
                Called whenever :meth:`Bottle.reset` is called.
        i    N(   t   _Bottle__hook_reversedR@  t   insertR   (   R~   R   R@   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   add_hook  s    c         C  s>   | |  j  k r: | |  j  | k r: |  j  | j |  t Sd S(   s     Remove a callback from a hook. N(   R@  t   removeR   (   R~   R   R@   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   remove_hook  s    "c         O  s(   g  |  j  | D] } | | |   ^ q S(   s.    Trigger a hook and return a list of results. (   R@  (   R~   t   _Bottle__nameR   RB   t   hook(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR1    s    c           s      f d   } | S(   se    Return a decorator that attaches a callback to a hook. See
            :meth:`add_hook` for details.c           s    j    |   |  S(   N(   RC  (   R@   (   R   R~   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt	   decorator  s    (    (   R~   R   RH  (    (   R   R~   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG    s    c           s   g  | j  d  D] } | r | ^ q } | s= t d   n  t |      f d   } | j d t  | j d d  | j d i | d 6  d	 6 | | d
 <|  j d d j |  |  | j d  s |  j d d j |  |  n  d  S(   NR   s+   WSGI applications cannot be mounted to "/".c            s   zl t  j   t g     d    f d  }   t  j |   }   j r^ t j   j |  n |   _   SWd  t  j   Xd  S(   Nc           s   | r t  |   n  t rk |  j d  j d  }  g  | D]* \ } } | | j d  j d  f ^ q8 } n  |    _ x$ | D] \ } }   j | |  q{ W  j j S(   NR6   RS   (   RN   R  RV   R\   t   statust
   add_headert   bodyR   (   RI  t
   headerlistt   exc_infot   kt   vR   R   (   t   rs(    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   start_response  s    7	(   t   requestt
   path_shiftt   HTTPResponseRW   R   RK  t	   itertoolst   chain(   RQ  RK  (   R   t
   path_depth(   RP  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   mountpoint_wrapper  s    't   skipR   R   t
   mountpointR   R   R  s   /%s/<:re:.*>(   t   splitR   R   R   R   t   routeR   t   endswith(   R~   R   R   t   optionsR   t   segmentsRX  (    (   R   RW  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _mount_wsgi  s    (
c         K  s  | |  j  k s d | j k rD t d d d d  |  j | | |  S| rp t d d d d  |  j | | |  S| j d  s t d d d	 d
  |  j | | |  S|  j  j |  | | j d <|  | j d <x7 | j D], } | | j j d  | _ |  j	 |  q Wd  S(   Ns
   _mount.appi    i   s?   Application mounted multiple times. Falling back to WSGI mount.s:   Clone application before mounting to a different location.s6   Unsupported mount options. Falling back to WSGI mount.sB   Do not specify any route options when mounting bottle application.R   s3   Prefix must end in '/'. Falling back to WSGI mount.s\   Consider adding an explicit redirect from '/prefix' to '/prefix/' in the parent application.s   _mount.prefix(
   R3  R
  Rt   R`  R]  R   R6  R   t   lstript	   add_route(   R~   R   R   R^  R\  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   _mount_app  s$    c         K  sW   | j  d  s t d   n  t | t  r@ |  j | | |  S|  j | | |  Sd S(   s   Mount an application (:class:`Bottle` or plain WSGI) to a specific
            URL prefix. Example::

                parent_app.mount('/prefix/', child_app)

            :param prefix: path prefix or `mount-point`.
            :param app: an instance of :class:`Bottle` or a WSGI application.

            Plugins from the parent application are not applied to the routes
            of the mounted child application. If you need plugins in the child
            application, install them separately.

            While it is possible to use path wildcards within the prefix path
            (:class:`Bottle` childs only), it is highly discouraged.

            The prefix path must end with a slash. If you want to access the
            root of the child application via `/prefix` in addition to
            `/prefix/`, consider adding a route with a 307 redirect to the
            parent application.
        R   s   Prefix must start with '/'N(   R   R   RT   R&  Rc  R`  (   R~   R   R   R^  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   mount  s
    c         C  s=   t  | t  r | j } n  x | D] } |  j |  q" Wd S(   s    Merge the routes of another :class:`Bottle` application or a list of
            :class:`Route` objects into this application. The routes keep their
            'owner', meaning that the :data:`Route.app` attribute is not
            changed. N(   RT   R&  R6  Rb  (   R~   R6  R\  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   merge  s    c         C  si   t  | d  r | j |   n  t |  rK t  | d  rK t d   n  |  j j |  |  j   | S(   s    Add a plugin to the list of plugins and prepare it for being
            applied to all routes of this application. A plugin may be a simple
            decorator or an object that implements the :class:`Plugin` API.
        t   setupR  s.   Plugins must be callable or implement .apply()(   RJ   Rf  t   callablet	   TypeErrorR  R   R  (   R~   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR9  !  s     
c         C  s   g  | } } x t  t |  j   d d d  D] \ } } | t k s~ | | k s~ | t |  k s~ t | d t  | k r0 | j |  |  j | =t | d  r | j   q q0 q0 W| r |  j	   n  | S(   s)   Uninstall plugins. Pass an instance to remove a specific plugin, a type
            object to remove all plugins that match that type, a string to remove
            all plugins with a matching ``name`` attribute or ``True`` to remove all
            plugins. Return the list of removed plugins. NiR   t   close(
   Rv   R   R  R   R  R   R   RJ   Ri  R  (   R~   R  t   removedRD  R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt	   uninstall-  s    /*
  c         C  s   | d k r |  j } n+ t | t  r3 | g } n |  j | g } x | D] } | j   qJ Wt r x | D] } | j   qk Wn  |  j d  d S(   s    Reset all routes (force plugins to be re-applied) and clear all
            caches. If an ID or route object is given, only that specific route
            is affected. R>  N(   RW   R6  RT   R  R  Rk   R  R1  (   R~   R\  R6  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  <  s      c         C  s4   x- |  j  D]" } t | d  r
 | j   q
 q
 Wd S(   s2    Close the application and all installed plugins. Ri  N(   R  RJ   Ri  (   R~   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRi  J  s     c         K  s   t  |  |  d S(   s-    Calls :func:`run` with the same parameters. N(   t   run(   R~   RB   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl  O  s    c         C  s   |  j  j |  S(   s    Search for a matching route and return a (:class:`Route`, urlargs)
            tuple. The second value is a dictionary with parameters extracted
            from the URL. Raise :exc:`HTTPError` (404/405) on a non-match.(   R7  R   (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   S  s    c         K  sV   t  j j d d  j d  d } |  j j | |  j d  } t t d |  |  S(   s,    Return a string that matches a named route t   SCRIPT_NAMERH   R   (   RR  R   R   t   stripR7  R   Ra  R0   (   R~   t	   routenamet   kargst
   scriptnamet   location(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   get_urlY  s    "c         C  sL   |  j  j |  |  j j | j | j | d | j t rH | j   n  d S(   sS    Add a route object, but do not change the :data:`Route.app`
            attribute.R   N(	   R6  R   R7  R   R   R   R   Rk   R  (   R~   R\  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRb  _  s    % R   c   	        si   t    r d   } n  t |   t |           f d   } | re | |  S| S(   s   A decorator to bind a function to a request URL. Example::

                @app.route('/hello/<name>')
                def hello(name):
                    return 'Hello %s' % name

            The ``<name>`` part is a wildcard. See :class:`Router` for syntax
            details.

            :param path: Request path or a list of paths to listen to. If no
              path is specified, it is automatically generated from the
              signature of the function.
            :param method: HTTP method (`GET`, `POST`, `PUT`, ...) or a list of
              methods to listen to. (default: `GET`)
            :param callback: An optional shortcut to avoid the decorator
              syntax. ``route(..., callback=func)`` equals ``route(...)(func)``
            :param name: The name for this route. (default: None)
            :param apply: A decorator or plugin or a list of plugins. These are
              applied to the route callback in addition to installed plugins.
            :param skip: A list of plugins, plugin classes or names. Matching
              plugins are not installed to this route. ``True`` skips all.

            Any additional keyword arguments are stored as route-specific
            configuration and passed to plugins (see :meth:`Plugin.apply`).
        c           s   t  |  t  r t |   }  n  xz t   p6 t |   D]` } xW t   D]I } | j   } t  | | |  d  d  d    }  j |  qJ Wq7 W|  S(   NR   R  R	  (   RT   t
   basestringt   loadR>   t   yieldroutesR   R  Rb  (   R  R   R  R\  (   R
  R   R   R   R  R~   R	  (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRH    s     N(   Rg  RW   R>   (	   R~   R   R   R  R   R  RY  R
  RH  (    (   R
  R   R   R   R  R~   R	  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR\  f  s      !c         K  s   |  j  | | |  S(   s    Equals :meth:`route`. (   R\  (   R~   R   R   R^  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    t   POSTc         K  s   |  j  | | |  S(   s8    Equals :meth:`route` with a ``POST`` method parameter. (   R\  (   R~   R   R   R^  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   post  s    t   PUTc         K  s   |  j  | | |  S(   s7    Equals :meth:`route` with a ``PUT`` method parameter. (   R\  (   R~   R   R   R^  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   put  s    t   DELETEc         K  s   |  j  | | |  S(   s:    Equals :meth:`route` with a ``DELETE`` method parameter. (   R\  (   R~   R   R   R^  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   delete  s    t   PATCHc         K  s   |  j  | | |  S(   s9    Equals :meth:`route` with a ``PATCH`` method parameter. (   R\  (   R~   R   R   R^  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   patch  s    i  c           s&      f d   } | r" | |  S| S(   s   Register an output handler for a HTTP error code. Can
            be used as a decorator or called directly ::

                def error_handler_500(error):
                    return 'error_handler_500'

                app.error(code=500, callback=error_handler_500)

                @app.error(404)
                def error_handler_404(error):
                    return 'error_handler_404'

        c           s5   t  |  t  r t |   }  n  |   j t    <|  S(   N(   RT   Rt  Ru  R8  R   (   R  (   t   codeR~   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRH    s     (    (   R~   R  R  RH  (    (   R  R~   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c      	   C  s%   t  t t d | d t d d   S(   NR   t   template_settingsR   t   __ERROR_PAGE_TEMPLATE(   RZ   t   templatet   ERROR_PAGE_TEMPLATERx   (   R~   t   res(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   default_error_handler  s    c         C  s  | d } | d <t  r: | j d  j d d  | d <n  |  | d <t j |  t j   yxt rud  } z yW |  j d  |  j	 j
 |  \ } } | | d <| | d	 <| | d
 <| j |   } PWnJ t k
 r } | } Pn1 t k
 rt d d d d  | j   wa n XWd  t | t  r7| j t  n  y |  j d  Wn& t k
 rp} | } | j t  n XXqa WWn t t t f k
 r  n| t k
 r} |  j s  n  t   } | d j |  | d j   t j   | d <t d d | |  } | j t  n X| S(   NR   s   bottle.raw_pathR6   RS   t   ignores
   bottle.appR<  s   route.handles   bottle.routes   route.url_argsi    i   s   RouteReset exception deprecateds<   Call route.call() after route.reset() and return the result.R=  s   wsgi.errorss   bottle.exc_infoi  s   Internal Server Error(   R  RV   R\   RR  t   bindt   responseR   RW   R1  R7  R   R  RT  R   Rt   R  RT   R  t   KeyboardInterruptt
   SystemExitt   MemoryErrort	   ExceptionR'  R+   t   writet   flushR`   RM  R   (   R~   R   R   t   outR\  R   R   t
   stacktrace(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _handle  sZ    "

	 



	 	c   
      C  s"  | s# d t  k r d t  d <n  g  St | t t f  rn t | d t t f  rn | d d d !j |  } n  t | t  r | j t  j  } n  t | t  r d t  k r t	 |  t  d <n  | g St | t
  r| j t   |  j j | j |  j  |  } |  j |  St | t  r=| j t   |  j | j  St | d  rd t j k rlt j d |  St | d  st | d  rt |  Sn  y5 t |  } t |  } x | st |  } qWWn t k
 r|  j d  St k
 r} | } nV t t t f k
 r  n: t k
 rW} |  j s<  n  t
 d d	 | t    } n Xt | t  rt|  j |  St | t  rt  j! | g |  } n_ t | t  rd
   } t" | t  j! | g |   } n& d t# |  }	 |  j t
 d |	   St | d  rt$ | | j%  } n  | S(   s    Try to convert the parameter into something WSGI compatible and set
        correct HTTP headers when possible.
        Support: False, str, unicode, dict, HTTPResponse, HTTPError, file-like,
        iterable of strings and iterable of unicodes
        s   Content-Lengthi    t   reads   wsgi.file_wrapperRi  t   __iter__RH   i  s   Unhandled exceptionc         S  s   |  j  t j  S(   N(   RV   R  t   charset(   RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   7  RH   s   Unsupported response type: %s(&   R  RT   Ru   Rv   RX   RU   R   RV   R  R   R   R  R8  R   t   status_codeR  t   _castRT  RK  RJ   RR  R   t   WSGIFileWrappert   itert   nextt   StopIterationR  R  R  R  R'  R+   RU  RV  RO   R  t
   _closeiterRi  (
   R~   R  t   peekt   ioutt   firstR   R   t   new_itert   encoderR   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    sj    			 	!c         C  s}  y |  j  |  j |   } t j d k s: | d d k r_ t | d  rV | j   n  g  } n  | j d  } | d k	 r | d =n  | t j   t j	 |  | SWn t
 t t f k
 r   n t k
 rx} |  j s   n  d	 t | j d
 d   } t r-| d t t |   t t    f 7} n  | d j |  | d j   d g } | d | t j    t |  g SXd S(   s    The bottle WSGI-interface. id   ie   i   i0  R   R   Ri  s   bottle.exc_infos4   <h1>Critical error while processing request: %s</h1>R   R   sD   <h2>Error:</h2>
<pre>
%s
</pre>
<h2>Traceback:</h2>
<pre>
%s
</pre>
s   wsgi.errorss   Content-Types   text/html; charset=UTF-8s   500 INTERNAL SERVER ERRORN(   id   ie   i   i0  (   s   Content-Types   text/html; charset=UTF-8(   R  R  R  t   _status_codeRJ   Ri  R   RW   t   _wsgi_status_lineRL  R  R  R  R  R'  t   html_escapeRk   R   R+   R  R  R`   RM  RZ   (   R~   R   RQ  R  RM  R   R]   t   headers(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   wsgi@  s6     	
	 &	c         C  s   |  j  | |  S(   s9    Each instance of :class:'Bottle' is a WSGI application. (   R  (   R~   R   RQ  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRI   ^  s    c         C  s   t  j |   |  S(   sA    Use this application as default for all module-level shortcuts. (   t   default_appt   push(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt	   __enter__b  s    c         C  s   t  j   d  S(   N(   R  R   (   R~   t   exc_typet	   exc_valuet	   traceback(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __exit__g  s    c         C  s3   | |  j  k r" t d |   n  | |  j  | <d  S(   Ns.   Attribute %s already defined. Plugin conflict?(   R   Rc   (   R~   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __setattr__j  s    (   R<  R=  R>  R
  N(,   R   R   R   R   R-  R   Rz   R'  R?  RA  R   R@  RC  RE  R1  RG  R`  Rc  Rd  Re  R9  Rk  RW   R  Ri  Rl  R   Rs  Rb  R\  R   Rx  Rz  R|  R~  R   R  R  R  R  RI   R  R  R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR&  Y  sV   	$					
	)			
							,		2I				t   BaseRequestc           B  sP  e  Z d  Z dA Z d Z dB d  Z e d d d e d    Z	 e d d d e d    Z
 e d d	 d e d
    Z e d    Z e d    Z e d d d e d    Z dB d  Z e d d d e d    Z dB dB e j d  Z e d d d e d    Z e d d d e d    Z e d d d e d    Z e d d d e d    Z e d d d e d    Z d   Z e d    Z e d d d e d     Z d!   Z e d"    Z e d#    Z  e Z! e d d$ d e d%    Z" e d&    Z# e d d' d e d(    Z$ e d)    Z% e d*    Z& e d+    Z' d, d-  Z( e d.    Z) e d/    Z* e d0    Z+ e d1    Z, e d2    Z- e d3    Z. e d4    Z/ d5   Z0 dB d6  Z1 d7   Z2 d8   Z3 d9   Z4 d:   Z5 d;   Z6 d<   Z7 d=   Z8 d>   Z9 d?   Z: d@   Z; RS(C   sd   A wrapper for WSGI environment dictionaries that adds a lot of
        convenient access methods and properties. Most of them are read-only.

        Adding new attributes to a request actually adds them to the environ
        dictionary (as 'bottle.request.ext.<name>'). This is the recommended
        way to store and access request-specific data.
    R   i  c         C  s,   | d k r i  n | |  _ |  |  j d <d S(   s!    Wrap a WSGI environ dictionary. s   bottle.requestN(   RW   R   (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    s
   bottle.appR}   c         C  s   t  d   d S(   s+    Bottle application handling this request. s0   This request is not connected to an application.N(   t   RuntimeError(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    s   bottle.routec         C  s   t  d   d S(   s=    The bottle :class:`Route` object that matches this request. s)   This request is not connected to a route.N(   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR\    s    s   route.url_argsc         C  s   t  d   d S(   s'    The arguments extracted from the URL. s)   This request is not connected to a route.N(   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c         C  s    d |  j  j d d  j d  S(   s    The value of ``PATH_INFO`` with exactly one prefixed slash (to fix
            broken clients and avoid the "empty path" edge case). R   R   RH   (   R   R   Ra  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c         C  s   |  j  j d d  j   S(   s6    The ``REQUEST_METHOD`` value as an uppercase string. R   R   (   R   R   R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    s   bottle.request.headersc         C  s   t  |  j  S(   sf    A :class:`WSGIHeaderDict` that provides case-insensitive access to
            HTTP request headers. (   t   WSGIHeaderDictR   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         C  s   |  j  j | |  S(   sA    Return the value of a request header, or a given default value. (   R  R   (   R~   R   R
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   get_header  s    s   bottle.request.cookiesc         C  s5   t  |  j j d d   j   } t d   | D  S(   s    Cookies parsed into a :class:`FormsDict`. Signed cookies are NOT
            decoded. Use :meth:`get_cookie` if you expect signed cookies. t   HTTP_COOKIERH   c         s  s!   |  ] } | j  | j f Vq d  S(   N(   R|   R   (   R   t   c(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>  s    (   R7   R   R   t   valuest	   FormsDict(   R~   t   cookies(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    !c   
      C  s   |  j  j |  } | r | r | j d  r d | k r t t | d j d d   \ } } t j t |  | d | j   } t	 | t
 j |   r t j t
 j |   }	 |	 r |	 d | k r |	 d Sq n  | S| p | S(   s   Return the content of a cookie. To read a `Signed Cookie`, the
            `secret` must match the one used to create the cookie (see
            :meth:`BaseResponse.set_cookie`). If anything goes wrong (missing
            cookie or wrong signature), return a default value. t   !R   i   t	   digestmodi    (   R  R   R   R  RZ   R[  t   hmact   newt   digestt   _lscmpt   base64t	   b64encodet   pickleR/   t	   b64decode(
   R~   R|   R
   t   secretR  R   t   sigR   t   hasht   dst(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   get_cookie  s    !%$s   bottle.request.queryc         C  sT   t    } |  j d <t |  j j d d   } x | D] \ } } | | | <q6 W| S(   s    The :attr:`query_string` parsed into a :class:`FormsDict`. These
            values are sometimes called "URL arguments" or "GET parameters", but
            not to be confused with "URL wildcards" as they are provided by the
            :class:`Router`. s
   bottle.gett   QUERY_STRINGRH   (   R  R   t
   _parse_qslR   (   R~   R   t   pairsR|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s
    s   bottle.request.formsc         C  sX   t    } |  j j | _ x9 |  j j   D]( \ } } t | t  s( | | | <q( q( W| S(   s   Form values parsed from an `url-encoded` or `multipart/form-data`
            encoded POST or PUT request body. The result is returned as a
            :class:`FormsDict`. All keys and values are strings. File uploads
            are stored separately in :attr:`files`. (   R  Rw  t   recode_unicodet   allitemsRT   t
   FileUpload(   R~   t   formsR   t   item(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    	s   bottle.request.paramsc         C  sa   t    } x' |  j j   D] \ } } | | | <q Wx' |  j j   D] \ } } | | | <qC W| S(   s    A :class:`FormsDict` with the combined values of :attr:`query` and
            :attr:`forms`. File uploads are stored in :attr:`files`. (   R  R   R  R  (   R~   t   paramsR|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    	s   bottle.request.filesc         C  sX   t    } |  j j | _ x9 |  j j   D]( \ } } t | t  r( | | | <q( q( W| S(   s    File uploads parsed from `multipart/form-data` encoded POST or PUT
            request body. The values are instances of :class:`FileUpload`.

        (   R  Rw  R  R  RT   R  (   R~   t   filesR   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    	s   bottle.request.jsonc         C  s   |  j  j d d  j   j d  d } | d	 k r |  j |  j  } | sP d
 Sy t |  SWq t t	 f k
 r t
 d d   q Xn  d
 S(   sL   If the ``Content-Type`` header is ``application/json`` or
            ``application/json-rpc``, this property holds the parsed content
            of the request body. Only requests smaller than :attr:`MEMFILE_MAX`
            are processed to avoid memory exhaustion.
            Invalid JSON raises a 400 error response.
        t   CONTENT_TYPERH   t   ;i    s   application/jsons   application/json-rpci  s   Invalid JSON(   s   application/jsons   application/json-rpcN(   R   R   t   lowerR[  t   _get_body_stringt   MEMFILE_MAXRW   t
   json_loadsR   Rh  R   (   R~   t   ctypet   b(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   json  s    (c         c  sW   t  d |  j  } x> | rR | t | |   } | s: Pn  | V| t |  8} q Wd  S(   Ni    (   t   maxt   content_lengtht   minR   (   R~   R  t   bufsizet   maxreadt   part(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   _iter_body  s    	 c         c  s  t  d d  } t d  t d  t d  } } } xYt r|  d  } xT | d | k r |  d  } | | 7} | s |  n  t |  | k rM |  qM qM W| j |  \ } }	 }	 y t t | j    d  }
 Wn t k
 r |  n X|
 d	 k rPn  | } xg |
 d	 k rq| s5|  t	 |
 |   } n  | |
  | |
 } } | sY|  n  | V|
 t |  8}
 qW|  d
  | k r8 |  q8 q8 Wd  S(   Ni  s*   Error while parsing chunked transfer body.s   
R  RH   i   ii   i    i   (
   R   RZ   R   R   t	   partitionR   t   tonatRn  R   R  (   R  R  R]   t   rnt   semt   bst   headerR  t   sizeR"   R  t   buffR  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _iter_chunked  s:    &	
 	 
  	s   bottle.request.bodyc         C  s  y |  j  d j } Wn) t k
 r? t   |  j  d <|  j  d SX|  j rR |  j n |  j } t   d t } } } x | | |  j  D]n } | j	 |  | t
 |  7} | r | |  j k r t d d  | } } | j	 | j    ~ t } q q W| |  j  d <| j d  | S(   Ns
   wsgi.inputi    R   s   w+b(   R   R  R   R<   t   chunkedR  R  R   R  R  R   R*   t   getvalueR   t   seek(   R~   t	   read_funct	   body_iterRK  t	   body_sizet   is_temp_fileR  t   tmp(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _body/  s$    c         C  s_   |  j  | k r! t d d   n  |  j j | d  } t |  | k r[ t d d   n  | S(   s[    Read body into a string. Raise HTTPError(413) on requests that are
            too large. i  s   Request entity too largei   (   R  R   RK  R  R   (   R~   R  Ry   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  D  s    c         C  s   |  j  j d  |  j  S(   sl   The HTTP request body as a seek-able file-like object. Depending on
            :attr:`MEMFILE_MAX`, this is either a temporary file or a
            :class:`io.BytesIO` instance. Accessing this property for the first
            time reads and replaces the ``wsgi.input`` environ variable.
            Subsequent accesses just do a `seek(0)` on the file object. i    (   R  R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRK  N  s    c         C  s   d |  j  j d d  j   k S(   s(    True if Chunked transfer encoding was. R  t   HTTP_TRANSFER_ENCODINGRH   (   R   R   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  X  s    s   bottle.request.postc   	      C  sc  t    } |  j j d  sa t |  j |  j  d  } x$ t |  D] \ } } | | | <qC W| Si d d 6} x1 d D]) } | |  j k ru |  j | | | <qu qu Wt d |  j	 d	 | d
 t
  } t r d | d <t | _ n  t j |   } | |  d <| j pg  } xX | D]P } | j d k r3| j | | j <qt | j | j | j | j  | | j <qW| S(   s    The values of :attr:`forms` and :attr:`files` combined into a single
            :class:`FormsDict`. Values are either strings (form values) or
            instances of :class:`cgi.FieldStorage` (file uploads).
        s
   multipart/R6   RH   R  R   R  t   CONTENT_LENGTHt   fpR   t   keep_blank_valuesRS   R5   s   _cgi.FieldStorage(   R   R  R  N(   R  t   content_typeR   R  R  R  R  R   Rx   RK  R   R  R   R  t   cgit   FieldStorageRv   t   filenameRW   R   R   R  R^   R  (	   R~   Rx  RK  R|   R   t   safe_envR   Ry   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRw  a  s.    	 

c         C  s   |  j  j   S(   s    The full request URI including hostname and scheme. If your app
            lives behind a reverse proxy or load balancer and you get confusing
            results, make sure that the ``X-Forwarded-Host`` header is set
            correctly. (   t   urlpartst   geturl(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    s   bottle.request.urlpartsc         C  s   |  j  } | j d  p' | j d d  } | j d  pE | j d  } | s | j d d  } | j d  } | r | | d k r d	 n d
 k r | d | 7} q n  t |  j  } t | | | | j d  d  S(   s    The :attr:`url` string as an :class:`urlparse.SplitResult` tuple.
            The tuple contains (scheme, host, path, query_string and fragment),
            but the fragment is always empty because it is not visible to the
            server. t   HTTP_X_FORWARDED_PROTOs   wsgi.url_schemet   httpt   HTTP_X_FORWARDED_HOSTt	   HTTP_HOSTt   SERVER_NAMEs	   127.0.0.1t   SERVER_PORTt   80t   443t   :R  RH   (   R   R   t   urlquotet   fullpatht   UrlSplitResult(   R~   t   envR  t   hostt   portR   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    	$c         C  s   t  |  j |  j j d   S(   s:    Request path including :attr:`script_name` (if present). R   (   R0   t   script_nameR   Ra  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         C  s   |  j  j d d  S(   sh    The raw :attr:`query` part of the URL (everything in between ``?``
            and ``#``) as a string. R  RH   (   R   R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   query_string  s    c         C  s4   |  j  j d d  j d  } | r0 d | d Sd S(   s    The initial portion of the URL's `path` that was removed by a higher
            level (server or routing middleware) before the application was
            called. This script path is returned with leading and tailing
            slashes. Rm  RH   R   (   R   R   Rn  (   R~   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    i   c         C  sC   t  |  j j d d  |  j |  \ } } | | |  d <|  d <d S(   s    Shift path segments from :attr:`path` to :attr:`script_name` and
            vice versa.

           :param shift: The number of path segments to shift. May be negative
                         to change the shift direction. (default: 1)
        Rm  R   R   N(   RS  R   R   R   (   R~   t   shiftt   scriptR   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRS    s    *c         C  s   t  |  j j d  p d  S(   s    The request body length as an integer. The client is responsible to
            set this header. Otherwise, the real length of the body is unknown
            and -1 is returned. In this case, :attr:`body` will be empty. R  i(   R   R   R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         C  s   |  j  j d d  j   S(   sA    The Content-Type header as a lowercase-string (default: empty). R  RH   (   R   R   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         C  s%   |  j  j d d  } | j   d k S(   s    True if the request was triggered by a XMLHttpRequest. This only
            works with JavaScript libraries that support the `X-Requested-With`
            header (most of the popular libraries do). t   HTTP_X_REQUESTED_WITHRH   t   xmlhttprequest(   R   R   R  (   R~   t   requested_with(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   is_xhr  s    c         C  s   |  j  S(   s9    Alias for :attr:`is_xhr`. "Ajax" is not the right term. (   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   is_ajax  s    c         C  sK   t  |  j j d d   } | r% | S|  j j d  } | rG | d f Sd S(   s   HTTP authentication data as a (user, password) tuple. This
            implementation currently supports basic (not digest) authentication
            only. If the authentication happened at a higher level (e.g. in the
            front web-server or a middleware), the password field is None, but
            the user field is looked up from the ``REMOTE_USER`` environ
            variable. On any errors, None is returned. t   HTTP_AUTHORIZATIONRH   t   REMOTE_USERN(   t
   parse_authR   R   RW   (   R~   t   basict   ruser(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   auth  s      
c         C  sa   |  j  j d  } | r> g  | j d  D] } | j   ^ q( S|  j  j d  } | r] | g Sg  S(   s(   A list of all IPs that were involved in this request, starting with
            the client IP and followed by zero or more proxies. This does only
            work if all proxies support the ```X-Forwarded-For`` header. Note
            that this information can be forged by malicious clients. t   HTTP_X_FORWARDED_FORR   t   REMOTE_ADDR(   R   R   R[  Rn  (   R~   t   proxyt   ipt   remote(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   remote_route  s
     &c         C  s   |  j  } | r | d Sd S(   sg    The client IP as a string. Note that this information can be forged
            by malicious clients. i    N(   R   RW   (   R~   R\  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   remote_addr  s    	c         C  s   t  |  j j    S(   sD    Return a new :class:`Request` with a shallow :attr:`environ` copy. (   t   RequestR   t   copy(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR#    s    c         C  s   |  j  j | |  S(   N(   R   R   (   R~   R   R
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c         C  s   |  j  | S(   N(   R   (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __getitem__  s    c         C  s   d |  | <|  j  | =d  S(   NRH   (   R   (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __delitem__  s    
c         C  s   t  |  j  S(   N(   R  R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         C  s   t  |  j  S(   N(   R   R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __len__  s    c         C  s   |  j  j   S(   N(   R   R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   	  s    c         C  s   |  j  j d  r! t d   n  | |  j  | <d } | d k rI d } n- | d
 k r^ d } n | j d  rv d } n  x% | D] } |  j  j d | d  q} Wd S(   sA    Change an environ value and clear all caches that depend on it. s   bottle.request.readonlys$   The environ dictionary is read-only.s
   wsgi.inputRK  R  R  R  Rx  R  R  R   t   HTTP_R  R  s   bottle.request.N(    (   RK  R  R  R  Rx  R  (   R   R  (   R  R  (   R   R   R   R   R   RW   (   R~   R|   R   t   todelete(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __setitem__  s    			c         C  s   d |  j  j |  j |  j f S(   Ns   <%s: %s %s>(   t	   __class__R   R   R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR%    s    c         C  s]   y5 |  j  d | } t | d  r0 | j |   S| SWn! t k
 rX t d |   n Xd S(   s@    Search in self.environ for additional user defined attributes. s   bottle.request.ext.%sR   s   Attribute %r not defined.N(   R   RJ   R   R   Rc   (   R~   R   t   var(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __getattr__"  s
    $c         C  s\   | d k r t  j |  | |  Sd | } t |  |  rK t d |   n  | |  j | <d  S(   NR   s   bottle.request.ext.%ss   Attribute already defined: %s(   t   objectR  RJ   Rc   R   (   R~   R   R   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  *  s     
c         C  s:   y |  j  d | =Wn! t k
 r5 t d |   n Xd  S(   Ns   bottle.request.ext.%ss   Attribute not defined: %s(   R   R   Rc   (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __delattr__1  s    (   R   N(<   R   R   R   t	   __slots__R  RW   R   Rz   R   R   R\  R   t   propertyR   R   R  R  R  t   hashlibt   sha256R  R   R  R  R  R  R  t   staticmethodR  R  R  RK  R  R   Rw  R   R  R  R  R  RS  R  R  R  R  R  R   R!  R#  R   R$  R%  R  R&  R   R)  R%  R,  R  R.  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  u  sf   		

"	
										c         C  sM   d |  k s$ d |  k s$ d |  k r7 t  d |    n  |  j   j d d  S(   Ns   
s   s    s4   Header names must not contain control characters: %rR"   t   -(   R   t   titlet   replace(   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _hkey8  s    $c         C  sG   t  |   }  d |  k s0 d |  k s0 d |  k rC t d |    n  |  S(   Ns   
s   s    s4   Header value must not contain control characters: %r(   R  R   (   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _hval>  s    $t   HeaderPropertyc           B  s5   e  Z d d d  d  Z d   Z d   Z d   Z RS(   RH   c         C  s=   | | |  _  |  _ | | |  _ |  _ d | j   |  _ d  S(   Ns   Current value of the %r header.(   R   R
   t   readert   writerR5  R   (   R~   R   R:  R;  R
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   F  s    c         C  sB   | d  k r |  S| j |  j |  j  } |  j r> |  j |  S| S(   N(   RW   R  R   R
   R:  (   R~   R   R"   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   K  s     c         C  s)   |  j  r |  j  |  n | | |  j <d  S(   N(   R;  R   (   R~   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   P  s    c         C  s   | |  j  =d  S(   N(   R   (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   S  s    N(   R   R   RW   R   R   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR9  E  s   		t   BaseResponsec        
   B  s  e  Z d  Z d Z d Z i e d.  d 6e d/  d 6Z d d0 d0 d  Z d0 d  Z	 d   Z
 d   Z e d    Z e d    Z d   Z d   Z e e e d0 d  Z [ [ e d    Z d   Z d   Z d   Z d   Z d0 d  Z d   Z d   Z d   Z d    Z e d!    Z e d  Z e d d" e d# d$ Z  e d% d" d&   d' d(   Z! e d) d*   Z" d0 e# j$ d+  Z% d,   Z& d-   Z' RS(1   s   Storage class for a response body as well as headers and cookies.

        This class does support dict-like case-insensitive item-access to
        headers, but is NOT a dict. Most notably, iterating over a response
        yields parts of the body and not the headers.

        :param body: The response body as one of the supported types.
        :param status: Either an HTTP status code (e.g. 200) or a status line
                       including the reason phrase (e.g. '200 OK').
        :param headers: A dictionary or a list of name-value pairs.

        Additional keyword arguments are added to the list of headers.
        Underscores in the header name are replaced with dashes.
    i   s   text/html; charset=UTF-8s   Content-Types   Content-Lengthi   R   s   Content-Encodings   Content-Languages   Content-Ranges   Content-Md5s   Last-Modifiedi0  RH   c         K  s   d  |  _ i  |  _ | |  _ | p' |  j |  _ | r{ t | t  rQ | j   } n  x' | D] \ } } |  j	 | |  qX Wn  | r x- | j   D] \ } } |  j	 | |  q Wn  d  S(   N(
   RW   t   _cookiest   _headersRK  t   default_statusRI  RT   Rx   t   itemsRJ  (   R~   RK  RI  R  t   more_headersR   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   s  s    			c         C  s   | p	 t  } t | t   s! t  |   } |  j | _ t d   |  j j   D  | _ |  j r t   } | _ x> |  j j   D]* \ } } | j	 | | <| | j
 |  q Wn  | S(   s    Returns a copy of self. c         s  s"   |  ] \ } } | | f Vq d  S(   N(    (   R   RN  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>  s    (   R<  t
   issubclasst   AssertionErrorRI  Rx   R>  R@  R=  R7   R   R2  (   R~   R   R#  R  RN  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR#    s    	"	c         C  s   t  |  j  S(   N(   R  RK  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         C  s&   t  |  j d  r" |  j j   n  d  S(   NRi  (   RJ   RK  Ri  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRi    s    c         C  s   |  j  S(   s;    The HTTP status line as a string (e.g. ``404 Not Found``).(   t   _status_line(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   status_line  s    c         C  s   |  j  S(   s/    The HTTP status code as an integer (e.g. 404).(   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         C  s   t  | t  r( | t j |  } } np d | k r d | k sX d | k sX d | k rg t d   n  | j   } t | j   d  } n t d   d | k o d	 k n s t d
   n  | |  _ t | p d |  |  _	 d  S(   Nt    s   
s   s    s+   Status line must not include control chars.i    s+   String status line without a reason phrase.id   i  s   Status code out of range.s
   %d Unknown(
   RT   R   t   _HTTP_STATUS_LINESR   R   Rn  R[  R  R   RD  (   R~   RI  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _set_status  s    $	c         C  s   |  j  S(   N(   RD  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _get_status  s    sQ   A writeable property to change the HTTP response status. It accepts
            either a numeric code (100-999) or a string with a custom reason
            phrase (e.g. "404 Brain not found"). Both :data:`status_line` and
            :data:`status_code` are updated accordingly. The return value is
            always a status string. c         C  s   t    } |  j | _ | S(   sl    An instance of :class:`HeaderDict`, a case-insensitive dict-like
            view on the response headers. (   t
   HeaderDictR>  Rx   (   R~   t   hdict(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    	c         C  s   t  |  |  j k S(   N(   R7  R>  (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   __contains__  s    c         C  s   |  j  t |  =d  S(   N(   R>  R7  (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR%    s    c         C  s   |  j  t |  d S(   Ni(   R>  R7  (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR$    s    c         C  s    t  |  g |  j t |  <d  S(   N(   R8  R>  R7  (   R~   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR)    s    c         C  s    |  j  j t |  | g  d S(   s|    Return the value of a previously defined header. If there is no
            header with that name, return a default value. i(   R>  R   R7  (   R~   R   R
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         C  s    t  |  g |  j t |  <d S(   sh    Create a new response header, replacing any previously defined
            headers with the same name. N(   R8  R>  R7  (   R~   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   set_header  s    c         C  s,   |  j  j t |  g   j t |   d S(   s=    Add an additional response header, not removing duplicates. N(   R>  R   R7  R   R8  (   R~   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRJ    s    c         C  s   |  j  S(   sx    Yield (header, value) tuples, skipping headers that are not
            allowed with the current response status code. (   RL  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   iter_headers  s    c         C  s&   t  r |  j j d  j d  S|  j S(   s.    WSGI conform status line (latin1-encodeable) RS   R6   (   R  RD  RV   R\   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         C  sS  g  } t  |  j j    } d |  j k rF | j d |  j g f  n  |  j |  j k r |  j |  j } g  | D] } | d | k ro | ^ qo } n  | g  | D]% \ } } | D] } | | f ^ q q 7} |  j rx9 |  j j   D]% } | j d t	 | j
    f  q Wn  t rOg  | D]* \ }	 }
 |	 |
 j d  j d  f ^ q} n  | S(   s.    WSGI conform list of (header, value) tuples. s   Content-Typei    s
   Set-CookieRS   R6   (   Rv   R>  R@  R   t   default_content_typeR  t   bad_headersR=  R  R8  t   OutputStringR  RV   R\   (   R~   R  R  RP  t   hR   t   valst   valR  RN  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRL    s    ,6	&:R:  R
   it   Expiresc         C  s   t  j t |    S(   N(   R(   t   utcfromtimestampt
   parse_date(   RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG     RH   R;  c         C  s
   t  |   S(   N(   t	   http_date(   RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG     RH   s   UTF-8c         C  s:   d |  j  k r6 |  j  j d  d j d  d j   S| S(   sJ    Return the charset specified in the content-type header (default: utf8). s   charset=iR  i    (   R  R[  Rn  (   R~   R
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    'c   	      K  s  |  j  s t   |  _  n  t d k  r: t j j d d  n  | r t | t  se t d d d d  n  t	 j
 t j | | g d	   } t	 j
 t j t |  | d
 | j    } t t d  | t d  |  } n t | t  s t d   n  t |  t |  d k r#t d   n  | |  j  | <x | j   D] \ } } | d k rd } t | t  r| j | j d d } qn  | d k rt |  } n  | d  k rd | pd j   } } | d! k rt d   qn  | d" k r| rq=n  | |  j  | | <q=Wd S(#   s   Create a new cookie or replace an old one. If the `secret` parameter is
            set, create a `Signed Cookie` (described below).

            :param name: the name of the cookie.
            :param value: the value of the cookie.
            :param secret: a signature key required for signed cookies.

            Additionally, this method accepts all RFC 2109 attributes that are
            supported by :class:`cookie.Morsel`, including:

            :param maxage: maximum age in seconds. (default: None)
            :param expires: a datetime object or UNIX timestamp. (default: None)
            :param domain: the domain that is allowed to read the cookie.
              (default: current domain)
            :param path: limits the cookie to a given path (default: current path)
            :param secure: limit the cookie to HTTPS connections (default: off).
            :param httponly: prevents client-side javascript to read this cookie
              (default: off, requires Python 2.6 or newer).
            :param samesite: Control or disable third-party use for this cookie.
              Possible values: `lax`, `strict` or `none` (default).

            If neither `expires` nor `maxage` is set (default), the cookie will
            expire at the end of the browser session (as soon as the browser
            window is closed).

            Signed cookies may store any pickle-able object and are
            cryptographically signed to prevent manipulation. Keep in mind that
            cookies are limited to 4kb in most browsers.

            Warning: Pickle is a potentially dangerous format. If an attacker
            gains access to the secret key, he could forge cookies that execute
            code on server side if unpickled. Using pickle is discouraged and
            support for it will be removed in later versions of bottle.

            Warning: Signed cookies are not encrypted (the client can still see
            the content) and not copy-protected (the client can restore an old
            cookie). The main intention is to make pickling and unpickling
            save, not to store secret information at client side.
        i   i   i    t   samesitet   SameSitei   s9   Pickling of arbitrary objects into cookies is deprecated.s:   Only store strings in cookies. JSON strings are fine, too.iR  R  R   s+   Secret key required for non-string cookies.i  s#   Content does not fit into a cookie.t   max_aget   maxages   max-agei   i  t   expirest	   same_sitet   nonet   laxR[   s   Invalid value for SameSitet   securet   httponlyN(   i   i   i    (   R[  R\  (   R^  RY  (   R`  R[   R_  (   Ra  Rb  (   R=  R7   t   pyR8   t	   _reservedR   RT   Rt  Rt   R  R  R  R.   R  R  RZ   R  RE   Rh  R   R   R@  R)   t   secondst   daysRX  R  R9   (	   R~   R   R   R  R  R^  t   encodedR  R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   set_cookie  s>    (	
!'c         K  s+   d | d <d | d <|  j  | d |  d S(   sq    Delete a cookie. Be sure to use the same `domain` and `path`
            settings as used to create the cookie. iR[  i    R]  RH   N(   Rh  (   R~   R|   RB   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   delete_cookieY  s    

c         C  sD   d } x7 |  j  D], \ } } | d | j   | j   f 7} q W| S(   NRH   s   %s: %s
(   RL  R5  Rn  (   R~   R  R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR%  `  s    $(   s   Content-Types   Content-Length(   R   s   Content-Encodings   Content-Languages   Content-Lengths   Content-Ranges   Content-Types   Content-Md5s   Last-ModifiedN((   R   R   R   R?  RO  t	   frozensetRP  RW   R   R#  R  Ri  R0  RE  R  RH  RI  RI  R  RL  R%  R$  R)  R  RM  RJ  RN  R  RL  R9  R  R   R  R]  R  R1  R2  Rh  Ri  R%  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR<  W  sT    															Q	c            sL   t  j       f d   }    f d   }   f d   } t |  | | d  S(   Nc           s/   y   j  SWn t k
 r* t d   n Xd  S(   Ns    Request context not initialized.(   R+  Rc   R  (   R"   (   t   ls(    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   fgetj  s    c           s   |   _  d  S(   N(   R+  (   R"   R   (   Rk  (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   fsetp  s    c           s
     `  d  S(   N(   R+  (   R"   (   Rk  (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   fdels  s    s   Thread-local property(   t	   threadingt   localR0  (   Rl  Rm  Rn  (    (   Rk  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _local_propertyg  s
    t   LocalRequestc           B  s    e  Z d  Z e j Z e   Z RS(   sT   A thread-local subclass of :class:`BaseRequest` with a different
        set of attributes for each thread. There is usually only one global
        instance of this class (:data:`request`). If accessed during a
        request/response cycle, this instance always refers to the *current*
        request (even on a multithreaded server). (   R   R   R   R  R   R  Rq  R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRr  y  s   	t   LocalResponsec           B  sD   e  Z d  Z e j Z e   Z e   Z e   Z	 e   Z
 e   Z RS(   s+   A thread-local subclass of :class:`BaseResponse` with a different
        set of attributes for each thread. There is usually only one global
        instance of this class (:data:`response`). Its attributes are used
        to build the HTTP response at the end of the request/response cycle.
    (   R   R   R   R<  R   R  Rq  RD  R  R=  R>  RK  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRs    s   					RT  c           B  s#   e  Z d  d d d  Z d   Z RS(   RH   c         K  s#   t  t |   j | | | |  d  S(   N(   t   superRT  R   (   R~   RK  RI  R  RA  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c         C  s@   |  j  | _  |  j | _ |  j | _ |  j | _ |  j | _ d  S(   N(   R  RD  R>  R=  RK  (   R~   t   other(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s
    N(   R   R   RW   R   R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRT    s   R   c           B  s#   e  Z d  Z d d d d d  Z RS(   i  c         K  s2   | |  _  | |  _ t t |   j | | |  d  S(   N(   t	   exceptionR  Rt  R   R   (   R~   RI  RK  Rv  R  RA  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    		N(   R   R   R?  RW   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s
   t   PluginErrorc           B  s   e  Z RS(    (   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRw    s   R:  c           B  s2   e  Z d  Z d Z e d  Z d   Z d   Z RS(   R  i   c         C  s   | |  _  d  S(   N(   t
   json_dumps(   R~   Rx  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c         C  s   | j  j d d t d t d d | j  j d d t d t d d | j  j d d t d t d d	 | j  j d
 d d  d d d  S(   Ns   json.enableR
   R(  R   s.   Enable or disable automatic dict->json filter.s
   json.asciis*   Use only 7-bit ASCII characters in output.s   json.indents*   Add whitespace to make json more readable.s   json.dump_funcs]   If defined, use this function to transform dict into json. The other options no longer apply.(   R
  t   _defineR   R+  R   RW   (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRf    s    c           s;   |  j   |  j  s   St j       f d    } | S(   Nc            s   y   |  |   } Wn t  k
 r. } | } n Xt | t  rW  |  } d t _ | St | t   r t | j t  r  | j  | _ d | _ n  | S(   Ns   application/json(   RT  RT   Rx   R  R  RK  (   RM   Ri   t   rvt   respt   json_response(   R  R.   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRg     s    
	!(   Rx  Re   t   wraps(   R~   R  R\  Rg   (    (   R  R.   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s
    		 !(   R   R   R   t   apiRx  R   Rf  R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR:    s
   	R;  c           B  s,   e  Z d  Z d Z d Z d   Z d   Z RS(   s   This plugin applies the :func:`view` decorator to all routes with a
        `template` config parameter. If the parameter is a tuple, the second
        element must be a dict with additional options (e.g. `template_engine`)
        or default variables for the template. R  i   c         C  s   |  | _  d  S(   N(   t   tpl(   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRf    s    c         C  s{   | j  j d  } t | t t f  rT t |  d k rT t | d | d  |  St | t  rs t |  |  S| Sd  S(   NR  i   i    i   (   R
  R   RT   Ru   Rv   R   t   viewR   (   R~   R  R\  R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    '(   R   R   R   R   R~  Rf  R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR;    s
   	t   _ImportRedirectc           B  s2   e  Z d    Z d d  Z d d  Z d   Z RS(   c         C  ss   | |  _  | |  _ t j j | t |   |  _ |  j j j i t	 d 6g  d 6g  d 6|  d 6 t j
 j |   d S(   s@    Create a virtual package that redirects imports (see PEP 302). t   __file__t   __path__t   __all__t
   __loader__N(   R   t   impmaskR`   t   modulesR   RP   t   moduleR   R2  R  t	   meta_pathR   (   R~   R   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    		c         C  sP   d | k r d  S| j  d d  d |  j k r3 d  Sd d l m } | | |   S(   Nt   .i   i    i(   t   spec_from_loader(   t   rsplitR   t   importlib.utilR  (   R~   t   fullnameR   R   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt	   find_spec  s      c         C  s7   d | k r d  S| j  d d  d |  j k r3 d  S|  S(   NR  i   i    (   R  R   (   R~   R  R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   find_module  s
      c         C  s   | t  j k r t  j | S| j d d  d } |  j | } t |  t  j | } t  j | <t |  j | |  |  | _ | S(   NR  i   (   R`   R  R  R  t
   __import__R   R  R  (   R~   R  t   modnamet   realnameR  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   load_module  s     
	N(   R   R   R   RW   R  R  R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   	t	   MultiDictc           B  s
  e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 e r d	   Z d
   Z d   Z e
 Z e Z e Z e Z n? d   Z d   Z d   Z d   Z d   Z d   Z d   Z d d d d  Z d   Z d   Z d   Z e Z e Z RS(   s    This dict stores multiple values per key, but behaves exactly like a
        normal dict in that it returns only the newest value for any given key.
        There are special methods available to access the full list of values.
    c         O  s,   t  d   t  | |   j   D  |  _  d  S(   Nc         s  s$   |  ] \ } } | | g f Vq d  S(   N(    (   R   RN  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>'  s    (   Rx   R@  (   R~   RM   RN  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   &  s    c         C  s   t  |  j  S(   N(   R   Rx   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR&  )  s    c         C  s   t  |  j  S(   N(   R  Rx   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  ,  s    c         C  s   | |  j  k S(   N(   Rx   (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRL  /  s    c         C  s   |  j  | =d  S(   N(   Rx   (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR%  2  s    c         C  s   |  j  | d S(   Ni(   Rx   (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR$  5  s    c         C  s   |  j  | |  d  S(   N(   R   (   R~   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR)  8  s    c         C  s   |  j  j   S(   N(   Rx   R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   ;  s    c         C  s   d   |  j  j   D S(   Nc         s  s   |  ] } | d  Vq d S(   iN(    (   R   RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>A  s    (   Rx   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  @  s    c         C  s   d   |  j  j   D S(   Nc         s  s%   |  ] \ } } | | d  f Vq d S(   iN(    (   R   RN  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>D  s    (   Rx   R@  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR@  C  s    c         C  s   d   |  j  j   D S(   Nc         s  s.   |  ]$ \ } } | D] } | | f Vq q d  S(   N(    (   R   RN  t   vlRO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>G  s    (   Rx   R@  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  F  s    c         C  s$   g  |  j  j   D] } | d ^ q S(   Ni(   Rx   R  (   R~   RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  P  s    c         C  s0   g  |  j  j   D] \ } } | | d f ^ q S(   Ni(   Rx   R@  (   R~   RN  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR@  S  s    c         C  s   |  j  j   S(   N(   Rx   t   iterkeys(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  V  s    c         C  s   d   |  j  j   D S(   Nc         s  s   |  ] } | d  Vq d S(   iN(    (   R   RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>Z  s    (   Rx   t
   itervalues(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  Y  s    c         C  s   d   |  j  j   D S(   Nc         s  s%   |  ] \ } } | | d  f Vq d S(   iN(    (   R   RN  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>]  s    (   Rx   t	   iteritems(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  \  s    c         C  s   d   |  j  j   D S(   Nc         s  s.   |  ]$ \ } } | D] } | | f Vq q d  S(   N(    (   R   RN  R  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>`  s    (   Rx   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   iterallitems_  s    c         C  s9   g  |  j  j   D]% \ } } | D] } | | f ^ q  q S(   N(   Rx   R  (   R~   RN  R  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  b  s    ic         C  sA   y) |  j  | | } | r$ | |  S| SWn t k
 r< n X| S(   s   Return the most recent value for a key.

            :param default: The default value to be returned if the key is not
                   present or the type conversion fails.
            :param index: An index for the list of available values.
            :param type: If defined, this callable is used to cast the value
                    into a specific type. Exception are suppressed and result in
                    the default value to be returned.
        (   Rx   R  (   R~   R|   R
   t   indexR  RT  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   e  s    
c         C  s    |  j  j | g   j |  d S(   s5    Add a new value to the list of values for this key. N(   Rx   R   R   (   R~   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   v  s    c         C  s   | g |  j  | <d S(   s1    Replace the list of values with a single value. N(   Rx   (   R~   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR6  z  s    c         C  s   |  j  j |  p g  S(   s5    Return a (possibly empty) list of values for a key. (   Rx   R   (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   getall~  s    N(   R   R   R   R   R&  R  RL  R%  R$  R)  R   R  R  R@  R  R  R  R  R  RW   R   R   R6  R  t   getonet   getlist(    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s<   																						R  c           B  sP   e  Z d  Z d Z e Z d d  Z d d  Z d d d  Z	 e
   d  Z RS(   s   This :class:`MultiDict` subclass is used to store request form data.
        Additionally to the normal dict-like item access methods (which return
        unmodified data as native strings), this container also supports
        attribute-like access to its values. Attributes are automatically de-
        or recoded to match :attr:`input_encoding` (default: 'utf8'). Missing
        attributes default to an empty string. RS   c         C  sd   t  | t  r7 |  j r7 | j d  j | p3 |  j  St  | t  r\ | j | pX |  j  S| Sd  S(   NR6   (   RT   RU   R  RV   R\   t   input_encodingRX   (   R~   RF   R5   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _fix  s
    c         C  sq   t    } | p |  j } | _ t | _ xB |  j   D]4 \ } } | j |  j | |  |  j | |   q5 W| S(   s    Returns a copy with all keys and values de- or recoded to match
            :attr:`input_encoding`. Some libraries (e.g. WTForms) want a
            unicode dictionary. (   R  R  R   R  R  R   R  (   R~   R5   R#  RY   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR\     s    		,c         C  s7   y |  j  |  | |  SWn t t f k
 r2 | SXd S(   s7    Return the value as a unicode string, or the default. N(   R  t   UnicodeErrorR   (   R~   R   R
   R5   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   getunicode  s    c         C  sG   | j  d  r4 | j d  r4 t t |   j |  S|  j | d | S(   Nt   __R
   (   R   R]  Rt  R  R,  R  (   R~   R   R
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR,    s    N(   R   R   R   R  R   R  RW   R  R\   R  RU   R,  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   RJ  c           B  sn   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d d	 d
  Z d   Z RS(   sz    A case-insensitive version of :class:`MultiDict` that defaults to
        replace the old value instead of appending it. c         O  s,   i  |  _  | s | r( |  j | |   n  d  S(   N(   Rx   R2  (   R~   RM   Ri   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    	 c         C  s   t  |  |  j k S(   N(   R7  Rx   (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRL    s    c         C  s   |  j  t |  =d  S(   N(   Rx   R7  (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR%    s    c         C  s   |  j  t |  d S(   Ni(   Rx   R7  (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR$    s    c         C  s    t  |  g |  j t |  <d  S(   N(   R8  Rx   R7  (   R~   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR)    s    c         C  s,   |  j  j t |  g   j t |   d  S(   N(   Rx   R   R7  R   R8  (   R~   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c         C  s    t  |  g |  j t |  <d  S(   N(   R8  Rx   R7  (   R~   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR6    s    c         C  s   |  j  j t |   p g  S(   N(   Rx   R   R7  (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    ic         C  s   t  j |  t |  | |  S(   N(   R  R   R7  (   R~   R|   R
   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c         C  s;   x4 d   | D D]" } | |  j  k r |  j  | =q q Wd  S(   Nc         s  s   |  ] } t  |  Vq d  S(   N(   R7  (   R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>  s    (   Rx   (   R~   t   namesR   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    N(   R   R   R   R   RL  R%  R$  R)  R   R6  R  RW   R   R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRJ    s   								R  c           B  sq   e  Z d  Z d Z d   Z d   Z d d  Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z RS(   s    This dict-like class wraps a WSGI environ dict and provides convenient
        access to HTTP_* fields. Keys and values are native strings
        (2.x bytes or 3.x unicode) and keys are case-insensitive. If the WSGI
        environment contains non-native string values, these are de- or encoded
        using a lossless 'latin1' character set.

        The API will remain stable even on changes to the relevant PEPs.
        Currently PEP 333, 444 and 3333 are supported. (PEP 444 is the only one
        that uses non-native strings.)
    R  R  c         C  s   | |  _  d  S(   N(   R   (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c         C  s3   | j  d d  j   } | |  j k r+ | Sd | S(   s6    Translate header field name to CGI/WSGI environ key. R4  R"   R'  (   R6  R   t   cgikeys(   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _ekey  s    c         C  s   |  j  j |  j |  |  S(   s:    Return the header value as is (may be bytes or unicode). (   R   R   R  (   R~   R|   R
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   raw  s    c         C  s\   |  j  |  j |  } t rX t | t  rF | j d  j d  } qX | j d  } n  | S(   NR6   RS   (   R   R  R  RT   RU   RV   R\   (   R~   R|   RT  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR$    s    c         C  s   t  d |  j   d  S(   Ns   %s is read-only.(   Rh  R*  (   R~   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR)   	  s    c         C  s   t  d |  j   d  S(   Ns   %s is read-only.(   Rh  R*  (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR%  	  s    c         c  sW   xP |  j  D]E } | d  d k r2 t | d  Vq
 | |  j k r
 t |  Vq
 q
 Wd  S(   Ni   R'  (   R   R7  R  (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  	  s
    c         C  s   g  |  D] } | ^ q S(   N(    (   R~   RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   	  s    c         C  s   t  |  j    S(   N(   R   R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR&  	  s    c         C  s   |  j  |  |  j k S(   N(   R  R   (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRL  	  s    (   R  R  N(   R   R   R   R  R   R  RW   R  R$  R)  R%  R  R   R&  RL  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   
									R)  c           B  s   e  Z d  Z d Z d   Z e d  Z d	   Z d
 d  Z d   Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z d   Z d d  Z d   Z d   Z e e e d  Z d   Z d   Z RS(   s"   A dict-like configuration storage with additional support for
        namespaces, validators, meta-data, overlays and more.

        This dict-like class is heavily optimized for read access. All read-only
        methods as well as item access should be as fast as the built-in dict.
    t   _metat   _change_listenert	   _overlayst   _virtual_keyst   _sourcet   __weakref__c         C  s4   i  |  _  g  |  _ g  |  _ d  |  _ t   |  _ d  S(   N(   R  R  R  RW   R  Rw   R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   "	  s
    				c           sO   t  |      f d   t    D } | r> |  j |  n |  j |  |  S(   s9  Load values from a Python module.

           Example modue ``config.py``::

                DEBUG = True
                SQLITE = {
                    "db": ":memory:"
                }


           >>> c = ConfigDict()
           >>> c.load_module('config')
           {DEBUG: True, 'SQLITE.DB': 'memory'}
           >>> c.load_module("config", False)
           {'DEBUG': True, 'SQLITE': {'DB': 'memory'}}

           :param squash: If true (default), dictionary values are assumed to
                          represent namespaces (see :meth:`load_dict`).
        c           s.   i  |  ]$ } | j    r t   |  |  q S(    (   t   isupperR   (   R   R|   (   t
   config_obj(    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys
   <dictcomp>A	  s   	 (   Ru  t   dirR  R2  (   R~   R   t   squashR   (    (   R  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  ,	  s    c         K  s   | j  d t  t r/ | j  d t j    n  t j |   } | j |  xm | j   D]_ } xV | j |  D]E } | j	 | |  } | d k r | d | } n  | |  | j
   <qn WqX W|  S(   s   Load values from an ``*.ini`` style config file.

            A configuration file consists of sections, each led by a
            ``[section]`` header, followed by key/value entries separated by
            either ``=`` or ``:``. Section names and keys are case-insensitive.
            Leading and trailing whitespace is removed from keys and values.
            Values can be omitted, in which case the key/value delimiter may
            also be left out. Values can also span multiple lines, as long as
            they are indented deeper than the first line of the value. Commands
            are prefixed by ``#`` or ``;`` and may only appear on their own on
            an otherwise empty line.

            Both section and key names may contain dots (``.``) as namespace
            separators. The actual configuration parameter name is constructed
            by joining section name and key name together and converting to
            lower case.

            The special sections ``bottle`` and ``ROOT`` refer to the root
            namespace and the ``DEFAULT`` section defines default values for all
            other sections.

            With Python 3, extended string interpolation is enabled.

            :param filename: The path of a config file, or a list of paths.
            :param options: All keyword parameters are passed to the underlying
                :class:`python:configparser.ConfigParser` constructor call.

        t   allow_no_valuet   interpolationt   bottlet   ROOTR  (   R  R  (   R   R   R  t   configparsert   ExtendedInterpolationt   ConfigParserR  t   sectionsR^  R   R  (   R~   R  R^  R   t   sectionR|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   load_configJ	  s    	RH   c         C  s   x | j    D]z \ } } t | t  rq | d | j d  } t | t  rd |  j | d | q | |  | <q t d t |    q W|  S(   s   Load values from a dictionary structure. Nesting can be used to
            represent namespaces.

            >>> c = ConfigDict()
            >>> c.load_dict({'some': {'namespace': {'key': 'value'} } })
            {'some.namespace.key': 'value'}
        R  t	   namespaces   Key has type %r (not a string)(   R@  RT   Rt  Rn  Rx   R  Rh  R  (   R~   t   sourceR  R|   R   t   nskey(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  u	  s    c         O  s{   d } | rC t  | d t  rC | d j d  d } | d } n  x1 t | |   j   D] \ } } | |  | | <qY Wd S(   s    If the first parameter is a string, all keys are prefixed with this
            namespace. Apart from that it works just as the usual dict.update().

            >>> c = ConfigDict()
            >>> c.update('some.namespace', key='value')
        RH   i    R  i   N(   RT   Rt  Rn  Rx   R@  (   R~   RM   Ri   R   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR2  	  s    "c         C  s!   | |  k r | |  | <n  |  | S(   N(    (   R~   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   	  s    c         C  s   t  | t  s( t d t |    n  |  j j |  |  j | d d    |  } | |  k rv |  | | k rv d  S|  j | |  t j	 |  | |  x$ |  j
   D] } | j | |  q Wd  S(   Ns   Key has type %r (not a string)R  c         S  s   |  S(   N(    (   RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   	  RH   (   RT   Rt  Rh  R  R  t   discardt   meta_gett
   _on_changeRx   R)  t   _iter_overlayst   _set_virtual(   R~   R|   R   t   overlay(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR)  	  s    c         C  s   | |  k r t  |   n  | |  j k r= t  d |   n  |  j r | |  j k r t j |  |  |  j | |  j |  nD |  j | d   t j |  |  x! |  j   D] } | j	 |  q Wd  S(   Ns"   Virtual keys cannot be deleted: %s(
   R   R  R  Rx   R%  R  R  RW   R  t   _delete_virtual(   R~   R|   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR%  	  s    c         C  s   | |  k r | |  j  k r d S|  j  j |  | |  k r^ |  | | k	 r^ |  j | |  n  t j |  | |  x$ |  j   D] } | j | |  q~ Wd S(   sa    Recursively set or update virtual keys. Do nothing if non-virtual
            value is present. N(   R  R   R  Rx   R)  R  R  (   R~   R|   R   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  	  s    c         C  sz   | |  j  k r d S| |  k r2 |  j | d  n  t j |  |  |  j  j |  x! |  j   D] } | j |  q_ Wd S(   sM    Recursively delete virtual entry. Do nothing if key is not virtual.
        N(   R  R  RW   Rx   R%  R  R  R  (   R~   R|   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  	  s    c         C  s.   x' |  j  D] } | |  | |  r
 t Sq
 Wd  S(   N(   R  R   (   R~   R|   R   R$  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  	  s    c         C  s   |  j  j |  | S(   N(   R  R   (   R~   R@   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR/  	  s    c         C  s   |  j  j | i   j | |  S(   s-    Return the value of a meta field for a key. (   R  R   (   R~   R|   t	   metafieldR
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  	  s    c         C  s   | |  j  j | i   | <d S(   s.    Set the meta field for a key to a new value. N(   R  R   (   R~   R|   R  R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR*  	  s    c         C  s   |  j  j | i   j   S(   s;    Return an iterable of meta field names defined for a key. (   R  R   R   (   R~   R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt	   meta_list	  s    c         C  sg   | t  k	 r |  j | |  n  | t  k	 rA |  j | d |  n  | t  k	 rc |  j | d |  n  d S(   sB    (Unstable) Shortcut for plugins to define own config parameters. R   R(  N(   t   _UNSETR   R*  (   R~   R|   R
   R   R(  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRy  	  s    c         c  s5   x. |  j  D]# } |   } | d  k	 r
 | Vq
 q
 Wd  S(   N(   R  RW   (   R~   t   refR  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  	  s    	c         C  s   g  |  j  D] } |   d k	 r
 | ^ q
 |  j  (t   } |  j | _ |  | _ |  j  j t j |   x" |  D] } | j | |  |  qm W| S(   s   (Unstable) Create a new overlay that acts like a chained map: Values
            missing in the overlay are copied from the source map. Both maps
            share the same meta entries.

            Entries that were copied from the source are called 'virtual'. You
            can not delete virtual keys, but overwrite them, which turns them
            into non-virtual entries. Setting keys on an overlay never affects
            its source, but may affect any number of child overlays.

            Other than collections.ChainMap or most other implementations, this
            approach does not resolve missing keys on demand, but instead
            actively copies all values from the source to the overlay and keeps
            track of virtual and non-virtual keys internally. This removes any
            lookup-overhead. Read-access is as fast as a build-in dict for both
            virtual and non-virtual keys.

            Changes are propagated recursively and depth-first. A failing
            on-change handler in an overlay stops the propagation of virtual
            values and may result in an partly updated tree. Take extra care
            here and make sure that on-change handlers never fail.

            Used by Route.config
        N(	   R  RW   R)  R  R  R   t   weakrefR  R  (   R~   R  R  R|   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  	  s    /		(   R  R  R  R  R  R  N(   R   R   R   R/  R   R   R  R  R  R2  R   R)  R%  R  R  R  R/  RW   R  R*  R  R  Ry  R  R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR)  	  s(   	
	+												t   AppStackc           B  s8   e  Z d  Z d   Z d d  Z e Z e d    Z RS(   s>    A stack-like list. Calling it returns the head of the stack. c         C  s   |  j  S(   s)    Return the current default application. (   R
   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRI   "
  s    c         C  s,   t  | t  s t   } n  |  j |  | S(   s1    Add a new :class:`Bottle` instance to the stack (   RT   R&  R   (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  &
  s    c         C  s+   y |  d SWn t  k
 r& |  j   SXd  S(   Ni(   t
   IndexErrorR  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR
   .
  s    N(	   R   R   R   RI   RW   R  t   new_appR0  R
   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  
  s
   	R  c           B  s   e  Z d d  Z d   Z RS(   i   i@   c         C  sS   | | |  _  |  _ x9 d D]1 } t | |  r t |  | t | |   q q Wd  S(   Nt   filenoRi  R  t	   readlinest   tellR  (   R  Ri  R  R  R  R  (   R  t   buffer_sizeRJ   R   R   (   R~   R  R  R{   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   7
  s     c         c  sA   |  j  |  j } } | |  } x | r< | V| |  } q" Wd  S(   N(   R  R  (   R~   R  R  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  <
  s
    	i   (   R   R   R   R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  6
  s   R  c           B  s,   e  Z d  Z d d  Z d   Z d   Z RS(   s    This only exists to be able to attach a .close method to iterators that
        do not support attribute assignment (most of itertools). c         C  s   | |  _  t |  |  _ d  S(   N(   t   iteratorR>   t   close_callbacks(   R~   R  Ri  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   H
  s    	c         C  s   t  |  j  S(   N(   R  R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  L
  s    c         C  s   x |  j  D] } |   q
 Wd  S(   N(   R  (   R~   R@   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRi  O
  s    N(   R   R   R   RW   R   R  Ri  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  D
  s   	R4  c           B  sP   e  Z d  Z d e d d  Z d	 d	 e d  Z d   Z d   Z	 d d  Z RS(
   sf   This class manages a list of search paths and helps to find and open
        application-bound resources (files).

        :param base: default value for :meth:`add_path` calls.
        :param opener: callable used to open resources.
        :param cachemode: controls which lookups are cached. One of 'all',
                         'found' or 'none'.
    s   ./t   allc         C  s1   | |  _  | |  _ | |  _ g  |  _ i  |  _ d  S(   N(   t   openert   baset	   cachemodeR   t   cache(   R~   R  R  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   ^
  s
    				c         C  s   t  j j t  j j | p |  j   } t  j j t  j j | t  j j |    } | t  j 7} | |  j k r |  j j |  n  | r t  j j |  r t  j	 |  n  | d k r |  j j |  n |  j j | |  |  j j   t  j j |  S(   s   Add a new path to the list of search paths. Return False if the
            path does not exist.

            :param path: The new search path. Relative paths are turned into
                an absolute and normalized form. If the path looks like a file
                (not ending in `/`), the filename is stripped off.
            :param base: Path used to absolutize relative search paths.
                Defaults to :attr:`base` which defaults to ``os.getcwd()``.
            :param index: Position within the list of search paths. Defaults
                to last index (appends to the list).

            The `base` parameter makes it easy to reference files installed
            along with a python module or package::

                res.add_path('./resources/', __file__)
        N(   t   osR   t   abspatht   dirnameR  R   t   sepRD  t   isdirt   makedirsRW   R   RB  R  t   cleart   exists(   R~   R   R  R  t   create(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   add_pathh
  s    '-c         c  s   |  j  } x | r | j   } t j  j |  s7 q n  xS t j |  D]B } t j  j | |  } t j  j |  r | j |  qG | VqG Wq Wd S(   s:    Iterate over all existing files in all registered paths. N(   R   R   R  R  t   listdirR   R   (   R~   t   searchR   R   t   full(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  
  s    
	  c         C  s   | |  j  k s t r x[ |  j D]P } t j j | |  } t j j |  r |  j d k rk | |  j  | <n  | Sq W|  j d k r d |  j  | <q n  |  j  | S(   s    Search for a resource and return an absolute file path, or `None`.

            The :attr:`path` list is searched in order. The first match is
            returned. Symlinks are followed. The result is cached to speed up
            future lookups. R  t   found(   R  R  N(   R  Rk   R   R  R   t   isfileR  RW   (   R~   R   R   t   fpath(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   lookup
  s    t   rc         O  sA   |  j  |  } | s( t d |   n  |  j | d | | | S(   s=    Find a resource and return a file object, or raise IOError. s   Resource %r not found.R   (   R  Rb   R  (   R~   R   R   R   RB   t   fname(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   open
  s     N(
   R   R   R   R  R   RW   R   R  R  R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR4  T
  s   
		R  c           B  sn   e  Z d d   Z e d  Z e d d e d d Z d d  Z e	 d    Z
 d d
  Z e d d  Z RS(   c         C  s=   | |  _  | |  _ | |  _ | r- t |  n t   |  _ d S(   s    Wrapper for file uploads. N(   R^   R   t   raw_filenameRJ  R  (   R~   t   fileobjR   R  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   
  s    			s   Content-Types   Content-LengthR:  R
   ic         C  s   |  j  j | |  S(   s9    Return the value of a header within the multipart part. (   R  R   (   R~   R   R
   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  
  s    c         C  s   |  j  } t | t  s- | j d d  } n  t d |  } | j d d  j d  } t j j | j	 d t j j
   } t j d d |  j   } t j d d	 |  j d
  } | d  p d S(   s   Name of the file on the client file system, but normalized to ensure
            file system compatibility. An empty filename is returned as 'empty'.

            Only ASCII letters, digits, dashes, underscores and dots are
            allowed in the final filename. Accents are removed, if possible.
            Whitespace is replaced by a single dash. Leading or tailing dots
            or dashes are removed. The filename is limited to 255 characters.
        RS   R  t   NFKDt   ASCIIs   \s   [^a-zA-Z0-9-_.\s]RH   s   [-\s]+R4  s   .-i   t   empty(   R  RT   RU   R\   R-   RV   R  R   t   basenameR6  R  R   R   Rn  (   R~   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  
  s    
	$i   i   c         C  sa   |  j  j | j |  j  j   } } } x$ | |  } | s? Pn  | |  q) W|  j  j |  d  S(   N(   R^   R  R  R  R  (   R~   R  t
   chunk_sizeR  R  R   t   buf(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   _copy_file
  s    & c         C  s   t  | t  r t j j |  r< t j j | |  j  } n  | rd t j j |  rd t d   n  t	 | d   } |  j
 | |  Wd QXn |  j
 | |  d S(   s   Save file to disk or copy its content to an open file(-like) object.
            If *destination* is a directory, :attr:`filename` is added to the
            path. Existing files are not overwritten by default (IOError).

            :param destination: File path, directory or file(-like) object.
            :param overwrite: If True, replace existing files. (default: False)
            :param chunk_size: Bytes to read at a time. (default: 64kb)
        s   File exists.t   wbN(   RT   Rt  R  R   R  R   R  R  Rb   R  R  (   R~   t   destinationt	   overwriteR  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   save
  s    	Ni   i   (   R   R   RW   R   R9  R  R   R  R  R   R  R  R   R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  
  s   i  s   Unknown Error.c         C  s   t  |  |   d S(   s+    Aborts execution and causes a HTTP error. N(   R   (   R  Rs   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   abort
  s    c         C  st   | s* t  j d  d k r! d n d } n  t j d t  } | | _ d | _ | j d t t  j	 |    |  d S(	   sd    Aborts execution and causes a 303 or 302 redirect, depending on
        the HTTP protocol version. t   SERVER_PROTOCOLs   HTTP/1.1i/  i.  R   RH   t   LocationN(
   RR  R   R  R#  RT  RI  RK  RM  R0   R   (   R   R  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   redirect
  s    $		i   c         c  s[   |  j  |  xG | d k rV |  j t | |   } | s> Pn  | t |  8} | Vq Wd S(   s&    Yield chunks from a range in a file. i    N(   R  R  R  R   (   R  R   t   limitR  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   _rangeiter  s    s   UTF-8c         C  s  t  j j t  j j |  d  } t  j j t  j j | |  j d    }  | r] | j   n i  } |  j |  s t d d  St  j j |   s t  j j	 |   r t d d  St  j
 |  t  j  s t d d  S| t k r5| r
| t k	 r
t j |  \ } } n t j |   \ } } | r5| | d <q5n  | r| d	  d
 k sW| d k rz| rzd | k rz| d | 7} n  | | d <n  | rt  j j | t k r|  n |  } d | | d <n  t  j |   } | j | d <}	 t j j | j d t | d <t j j t j   d t | d <t j j }
 | d( k r{d | j | j | j |	 |  f } t j t |   j    } n  | r| | d <|
 d  } | r| | k rt! d d |  Sn  |
 d  } | r!t" | j# d  d j    } | d( k	 r!| t$ | j  k r!t! d d |  Sn  t j% d k r6d n t& |  d  } d | d  <|
 d!  } | rt' t( | |	   } | st d" d#  S| d \ } } | | } d$ | | d% |	 f | d& <t) |  | d <| rt* t+ | | |  | j,  } n  t! | d d' | St! | |  S()   s   Open a file in a safe way and return an instance of :exc:`HTTPResponse`
        that can be sent back to the client.

        :param filename: Name or path of the file to send, relative to ``root``.
        :param root: Root path for file lookups. Should be an absolute directory
            path.
        :param mimetype: Provide the content-type header (default: guess from
            file extension)
        :param download: If True, ask the browser to open a `Save as...` dialog
            instead of opening the file with the associated program. You can
            specify a custom filename as a string. If not specified, the
            original filename is used (default: False).
        :param charset: The charset for files with a ``text/*`` mime-type.
            (default: UTF-8)
        :param etag: Provide a pre-computed ETag header. If set to ``False``,
            ETag handling is disabled. (default: auto-generate ETag header)
        :param headers: Additional headers dict to add to the response.

        While checking user input is always a good idea, this function provides
        additional protection against malicious ``filename`` parameters from
        breaking out of the ``root`` directory and leaking sensitive information
        to an attacker.

        Read-protected files or files outside of the ``root`` directory are
        answered with ``403 Access Denied``. Missing files result in a
        ``404 Not Found`` response. Conditional requests (``If-Modified-Since``,
        ``If-None-Match``) are answered with ``304 Not Modified`` whenever
        possible. ``HEAD`` and ``Range`` requests (used by download managers to
        check or continue partial downloads) are also handled automatically.

    RH   s   /\i  s   Access denied.i  s   File does not exist.s/   You do not have permission to access this file.s   Content-Encodingi   s   text/s   application/javascriptR  s   ; charset=%ss   Content-Types   attachment; filename="%s"s   Content-Dispositions   Content-Lengtht   usegmts   Last-Modifiedt   Dates   %d:%d:%d:%d:%st   ETagt   HTTP_IF_NONE_MATCHRI  i0  t   HTTP_IF_MODIFIED_SINCER  i    R   t   rbRX   s   Accept-Rangest
   HTTP_RANGEi  s   Requested Range Not Satisfiables   bytes %d-%d/%di   s   Content-Rangei   N(-   R  R   R   R  Rn  R#  R   R   R  R  t   accesst   R_OKR   t	   mimetypest
   guess_typeR  t   statt   st_sizet   emailt   utilst
   formatdatet   st_mtimet   timeRR  R   R   RW   t   st_devt   st_inoR1  t   sha1RZ   t	   hexdigestRT  RW  R[  R   R   R  Rv   t   parse_range_headerR   R  R  Ri  (   R  t   roott   mimetypet   downloadR  t   etagR  R5   t   statst   clent   getenvt   checkt   imsRK  t   range_headert   rangesR   R   t   rlen(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   static_file  st    &!*&$"
!$

 !c         C  s&   |  r t  j d  n  t |   a d S(   sS    Change the debug level.
    There is only one debug level supported at the moment.R
   N(   Rm   t   simplefilterR+  Rk   (   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   debug~  s     c         C  s   t  |  t  r |  St  |  t  r1 |  j   }  n t  |  t  rO |  j   }  n  t  |  t t f  sv t j	 |   }  n  t
 j j |  d t S(   NR   (   RT   Rt  R(   t   utctimetuplet   datedatet	   timetupleR   R   t   calendart   timegmR  R  R  R   (   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRX    s    c         C  s^   y9 t  j j |   } t j | d  d  | d p6 d SWn t t t t f k
 rY d SXd S(   sD    Parse rfc1123, rfc850 and asctime timestamps and return UTC epoch. i   i    i	   N(   i    (
   R  R  t   parsedate_tzR)  R*  Rh  R   R  t   OverflowErrorRW   (   R  t   ts(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRW    s
    'c         C  s   ye |  j  d d  \ } } | j   d k rd t t j t |    j  d d  \ } } | | f SWn t t f k
 r d SXd S(   s]    Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or Nonei   R  R  N(	   R[  RW   R  RE   R  R  RZ   R   R   (   R  R   Ry   t   usert   pwd(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    -i    c         c  s,  |  s |  d  d k r d Sg  |  d j  d  D]$ } d | k r/ | j  d d  ^ q/ } x | D] \ } } y | s t d | t |   | } } nB | s t |  | } } n& t |  t t |  d |  } } d | k o | k  o | k n r| | f Vn  Wq` t k
 r#q` Xq` Wd S(   s~    Yield (start, end) ranges parsed from a HTTP Range header. Skip
        unsatisfiable ranges. The end index is non-inclusive.i   s   bytes=NR   R4  i   i    (   R[  R  R   R  R   (   R  t   maxlenR  R!  R   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s     >#&'s-   (?:(?:"((?:[^"\\]|\\.)*)")|([^;,=]+))([;,=]?)c         C  s  g  } d |  k r xj|  j  d  D]} } | j  d  } | j | d j   i  f  xH | d D]< } | j  d d  \ } } | j   | d d | j   <q_ Wq" Wn d d
 i  } } } x t |   D] \ }	 }
 } |
 r |
 j   n |	 j d d  } | d k r"i  } | j | | f  nS | d k rP| d k rC| } qud	 | | <n% | d k ru| ru| | | <d
 } n  | } q W| S(   s   Parses a typical multi-valued and parametrised HTTP header (e.g. Accept headers) and returns a list of values
        and parameters. For non-standard or broken input, this implementation may return partial results.
    :param h: A header string (e.g. ``text/html,text/plain;q=0.9,*/*;q=0.8``)
    :return: List of (value, params) tuples. The second element is a (possibly empty) dict.
    t   "R   R  i    i   t   =is   \"RH   N(   R[  R   Rn  RW   t   _hsplitR6  (   RR  R  R   t   partsR{   R   t   lopR|   t   attrst   quotedt   plaint   tok(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _parse_http_header  s.    )$	
	
c         C  s   g  } x |  j  d  D] } | s( q n  | j  d d  } t |  d k r\ | j d  n  t | d j d d   } t | d j d d   } | j | | f  q W| S(	   Nt   &R2  i   i   RH   i    t   +RF  (   R[  R   R   t
   urlunquoteR6  (   t   qsR  t   pairt   nvR|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s      c         C  s6   t  d   t |  |  D  o5 t |   t |  k S(   ss    Compares two strings in a cryptographically safe way:
        Runtime is not affected by length of common prefix. c         s  s-   |  ]# \ } } | | k r! d  n d Vq d S(   i    i   N(    (   R   RK   t   y(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>  s   (   t   sumt   zipR   (   RM   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    	c         C  s   t  d d d d  | p t j } t j t j |  d   } t j t j t	 |  | d | j
    } t	 d  | t	 d  | S(	   s>    Encode and sign a pickle-able object. Return a (byte) string i    i   s%   cookie_encode() will be removed soon.s   Do not use this API directly.iR  R  R   (   Rt   R1  R2  R  R  R  R.   R  R  RZ   R  (   Ry   R|   R  R   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   cookie_encode  s    -c         C  s   t  d d d d  t |   }  t |   r |  j t d  d  \ } } | pU t j } t j t |  | d | j   } t	 | d t
 j |   r t j t
 j |   Sn  d S(	   s?    Verify and decode an encoded string. Return an object or None.i    i   s%   cookie_decode() will be removed soon.s   Do not use this API directly.R   i   R  N(   Rt   RZ   t   cookie_is_encodedR[  R1  R2  R  R  R  R  R  R  R  R/   R  RW   (   Ry   R|   R  R  R   t   hashed(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   cookie_decode  s    $c         C  s>   t  d d d d  t |  j t d   o: t d  |  k  S(   s9    Return True if the argument looks like a encoded cookie.i    i   s)   cookie_is_encoded() will be removed soon.s   Do not use this API directly.R  R   (   Rt   R+  R   RZ   (   Ry   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRE    s    c         C  s@   |  j  d d  j  d d  j  d d  j  d d  j  d	 d
  S(   s;    Escape HTML special characters ``&<>`` and quotes ``'"``. R;  s   &amp;t   <s   &lt;t   >s   &gt;R1  s   &quot;t   's   &#039;(   R6  (   t   string(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    *c         C  s2   d t  |   j d d  j d d  j d d  S(   s;    Escape and quote a string to be used as an HTTP attribute.s   "%s"s   
s   &#10;s   s   &#13;s   	s   &#9;(   R  R6  (   RK  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   html_quote  s    c         c  s   d |  j  j d d  j d  } t |   } t | d  t | d pK g   } | d | t | d |   7} | Vx) | d | D] } | d | 7} | Vq Wd S(   s   Return a generator for routes that match the signature (name, args)
    of the func parameter. This may yield more than one route if the function
    takes optional keyword arguments. The output is best described by example::

        a()         -> '/a'
        b(x, y)     -> '/b/<x>/<y>'
        c(x, y=5)   -> '/c/<x>' and '/c/<x>/<y>'
        d(x=5, y=6) -> '/d' and '/d/<x>' and '/d/<x>/<y>'
    R   R  i    i   s   /<%s>N(   R   R6  Ra  RC   R   Ru   (   R@   R   RA   t   argct   arg(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRv    s    
"$ i   c   	      C  s  | d k r |  | f S| j  d  j d  } |  j  d  j d  } | re | d d k re g  } n  | r | d d k r g  } n  d | k  o t |  k n r | |  } | | } | | } nl d | k o t |  k n r| | } | | } | |  } n( | d k  rd n d } t d |   d d j |  } d d j |  } | j d  r{| r{| d 7} n  | | f S(   sS   Shift path fragments from PATH_INFO to SCRIPT_NAME and vice versa.

        :return: The modified paths.
        :param script_name: The SCRIPT_NAME path.
        :param script_name: The PATH_INFO path.
        :param shift: The number of path fragments to shift. May be negative to
          change the shift direction. (default: 1)
    i    R   RH   Rm  R   s"   Cannot shift. Nothing left from %s(   Rn  R[  R   RC  R   R]  (	   R  t	   path_infoR  t   pathlistt
   scriptlistt   movedR  t   new_script_namet   new_path_info(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRS  3  s.    	 
 	 	"

#

 t   privates   Access deniedc           s       f d   } | S(   se    Callback decorator to require HTTP auth (basic).
        TODO: Add route(check_auth=...) parameter. c           s+   t  j         f d    } | S(   Nc            se   t  j p d \ } } | d  k s1   | |  rX t d   } | j d d   | S |  |   S(   Ni  s   WWW-Authenticates   Basic realm="%s"(   NN(   RR  R  RW   R   RJ  (   RM   Ri   R.  t   passwordR]   (   R  R@   t   realmRs   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRg   X  s    (   Re   R}  (   R@   Rg   (   R  RW  Rs   (   R@   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRH  V  s    '	(    (   R  RW  Rs   RH  (    (   R  RW  Rs   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   auth_basicR  s    c           s+   t  j t t       f d    } | S(   sA    Return a callable that relays calls to the current default app. c            s   t  t      |  |   S(   N(   R   R   (   RM   Ri   (   R   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRg   l  s    (   Re   R}  R   R&  (   R   Rg   (    (   R   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   make_default_app_wrapperi  s    'R\  R   Rx  Rz  R|  R~  R   Rd  RG  R9  Rk  Rs  t   ServerAdapterc           B  s/   e  Z e Z d  d d  Z d   Z d   Z RS(   s	   127.0.0.1i  c         K  s%   | |  _  | |  _ t |  |  _ d  S(   N(   R^  R
  R   R  (   R~   R
  R  R^  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    		c         C  s   d  S(   N(    (   R~   t   handler(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    c         C  s6   d j  d   |  j j   D  } d |  j j | f S(   Ns   , c         s  s+   |  ]! \ } } d  | t  |  f Vq d S(   s   %s=%sN(   R   (   R   RN  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>  s   s   %s(%s)(   R   R^  R@  R*  R   (   R~   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR%    s    (   R   R   R   t   quietR   Rl  R%  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRZ    s   	t	   CGIServerc           B  s   e  Z e Z d    Z RS(   c           s3   d d l  m }   f d   } |   j |  d  S(   Ni(   t
   CGIHandlerc           s   |  j  d d    |  |  S(   NR   RH   (   R   (   R   RQ  (   R[  (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   fixed_environ  s    (   t   wsgiref.handlersR^  Rl  (   R~   R[  R^  R_  (    (   R[  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    (   R   R   R   R\  Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR]    s   t   FlupFCGIServerc           B  s   e  Z d    Z RS(   c         C  sN   d d  l  } |  j j d |  j |  j f  | j j j | |  j  j   d  S(   Nit   bindAddress(	   t   flup.server.fcgiR^  R   R
  R  R   t   fcgit
   WSGIServerRl  (   R~   R[  t   flup(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    (   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRa    s   t   WSGIRefServerc           B  s   e  Z d    Z RS(   c           s-  d d l  m } d d l  m   m } d d  l  d   f    f d     Y}  j j d |  }  j j d |  } d  j k r t | d	   j	 k r d
 | f  f d     Y} q n  |  j  j
 | | |   _  j j  _
 y  j j   Wn! t k
 r( j j     n Xd  S(   Ni(   t   make_server(   t   WSGIRequestHandlerRe  t   FixedHandlerc             s#   e  Z d    Z    f d   Z RS(   c         S  s   |  j  d S(   Ni    (   t   client_address(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   address_string  s    c            s    j  s   j |  |   Sd  S(   N(   R\  t   log_request(   R   t   kw(   Ri  R~   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRm    s    	(   R   R   Rl  Rm  (    (   Ri  R~   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRj    s   	t   handler_classt   server_classR  t   address_familyt
   server_clsc             s   e  Z   j Z RS(    (   R   R   t   AF_INET6Rq  (    (   t   socket(    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRr    s   (   t   wsgiref.simple_serverRh  Ri  Re  Rt  R^  R   R
  R   t   AF_INETR  t   srvt   server_portt   serve_foreverR  t   server_close(   R~   R   Rh  Re  Rj  t   handler_clsRr  (    (   Ri  R~   Rt  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s"    "(   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRg    s   t   CherryPyServerc           B  s   e  Z d    Z RS(   c         C  s   t  d d d d  d d l m } |  j |  j f |  j d <| |  j d <|  j j d	  } | rn |  j d	 =n  |  j j d
  } | r |  j d
 =n  | j |  j   } | r | | _ n  | r | | _	 n  z | j
   Wd  | j   Xd  S(   Ni    i   sO   The wsgi server part of cherrypy was split into a new project called 'cheroot'.s5   Use the 'cheroot' server adapter instead of cherrypy.i(   t
   wsgiservert	   bind_addrt   wsgi_appt   certfilet   keyfile(   Rt   t   cherrypyR}  R
  R  R^  R   t   CherryPyWSGIServert   ssl_certificatet   ssl_private_keyR   t   stop(   R~   R[  R}  R  R  R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s&    (   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR|    s   t   CherootServerc           B  s   e  Z d    Z RS(   c         C  s   d d l  m } d d l m } |  j |  j f |  j d <| |  j d <|  j j d d   } |  j j d d   } |  j j d d   } | j	 |  j   } | r | r | j
 | | |  | _ n  z | j   Wd  | j   Xd  S(	   Ni(   R  (   t   builtinR~  R  R  R  t	   chainfile(   t   cherootR  t   cheroot.sslR  R
  R  R^  R   RW   t   Servert   BuiltinSSLAdaptert   ssl_adapterR   R  (   R~   R[  R  R  R  R  R  R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    (   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t   WaitressServerc           B  s   e  Z d    Z RS(   c      	   C  s?   d d l  m } | | d |  j d |  j d |  j |  j d  S(   Ni(   t   serveR
  R  t   _quiet(   t   waitressR  R
  R  R\  R^  (   R~   R[  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    (   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t   PasteServerc           B  s   e  Z d    Z RS(   c         C  se   d d l  m } d d l m } | | d |  j } | j | d |  j d t |  j  |  j	 d  S(   Ni(   t
   httpserver(   t   TransLoggert   setup_console_handlerR
  R  (
   t   pasteR  t   paste.transloggerR  R\  R  R
  R   R  R^  (   R~   R[  R  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    	(   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t   MeinheldServerc           B  s   e  Z d    Z RS(   c         C  s:   d d l  m } | j |  j |  j f  | j |  d  S(   Ni(   R   (   t   meinheldR   t   listenR
  R  Rl  (   R~   R[  R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    (   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t   FapwsServerc           B  s   e  Z d  Z d   Z RS(   sR    Extremely fast webserver using libev. See https://github.com/william-os4y/fapws3 c           s   t  d d d  d d  l j } d d l m } m } |  j } t | j d  d k rf t	 |  } n  | j
 |  j |  d t j k r |  j r t d	  t d
  n  | j |    f d   } | j d | f  | j   d  S(   Ni    i   s5   fapws3 is not maintained and support will be dropped.i(   R  R
  ig?t   BOTTLE_CHILDs2   WARNING: Auto-reloading does not work with Fapws3.s.            (Fapws3 breaks python thread support)c           s   t  |  d <  |  |  S(   Ns   wsgi.multiprocess(   R   (   R   RQ  (   R[  (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR   '  s    
RH   (   Rt   t   fapws._evwsgit   _evwsgit   fapwsR  R
  R  R   t   SERVER_IDENTR   R   R
  R  R   R\  Rd   t   set_base_modulet   wsgi_cbRl  (   R~   R[  t   evwsgiR  R
  R  R   (    (   R[  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    	
(   R   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t   TornadoServerc           B  s   e  Z d  Z d   Z RS(   s<    The super hyped asynchronous server by facebook. Untested. c         C  s~   d d  l  } d d  l } d d  l } | j j |  } | j j |  } | j d |  j d |  j	  | j
 j j   j   d  S(   NiR  t   address(   t   tornado.wsgit   tornado.httpservert   tornado.ioloopR  t   WSGIContainerR  t
   HTTPServerR  R  R
  t   ioloopt   IOLoopt   instanceR   (   R~   R[  t   tornadot	   containerR   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl  2  s
    $(   R   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  /  s   t   AppEngineServerc           B  s   e  Z d  Z e Z d   Z RS(   s     Adapter for Google App Engine. c           st   t  d d d d  d d l m  t j j d  } | rc t | d  rc    f d	   | _ n   j    d  S(
   Ni    i   s"   AppEngineServer no longer requireds4   Configure your application directly in your app.yamli(   t   utilR%   t   mainc             s    j     S(   N(   t   run_wsgi_app(    (   R[  R  (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   F  RH   (	   Rt   t   google.appengine.ext.webappR  R`   R  R   RJ   R  R  (   R~   R[  R  (    (   R[  R  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl  >  s    (   R   R   R   R   R\  Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  :  s   t   TwistedServerc           B  s   e  Z d  Z d   Z RS(   s    Untested. c         C  s   d d l  m } m } d d l m } d d l m } |   } | j   | j d d | j	  | j
 | j | | |   } | j |  j | d |  j | j s | j   n  d  S(   Ni(   R   R  (   t
   ThreadPool(   t   reactort   aftert   shutdownt	   interface(   t   twisted.webR   R  t   twisted.python.threadpoolR  t   twisted.internetR  R   t   addSystemEventTriggerR  t   Sitet   WSGIResourcet	   listenTCPR  R
  t   runningRl  (   R~   R[  R   R  R  R  t   thread_poolt   factory(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl  M  s    	
	(   R   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  J  s   t   DieselServerc           B  s   e  Z d  Z d   Z RS(   s    Untested. c         C  sC   t  d d d  d d l m } | | d |  j } | j   d  S(   Ni    i   s6   Diesel is not tested or supported and will be removed.i(   t   WSGIApplicationR  (   Rt   t   diesel.protocols.wsgiR  R  Rl  (   R~   R[  R  R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl  ]  s    (   R   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  Z  s   t   GeventServerc           B  s   e  Z d  Z d   Z RS(   s`    Untested. Options:

        * See gevent.wsgi.WSGIServer() documentation for more options.
    c           s   d d l  m } m } t t j   | j  sC d } t |   n  |  j r\ d  |  j d <n  |  j	 |  j
 f } | j | | |  j    d t j k r d d  l } | j | j   f d    n    j   d  S(   Ni(   t   pywsgiRp  s9   Bottle requires gevent.monkey.patch_all() (before import)t   logR  c           s
     j    S(   N(   R  (   RF   R   (   R   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   u  RH   (   R   R  Rp  RT   Ro  R  R\  RW   R^  R
  R  Re  R  R   t   signalt   SIGINTRy  (   R~   R[  R  Rp  R   R  R  (    (   R   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl  j  s    	(   R   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  d  s   t   GunicornServerc           B  s   e  Z d  Z d   Z RS(   s?    Untested. See http://gunicorn.org/configure.html for options. c           s   d d l  m } |  j j d  r5 i |  j d 6  n i d |  j |  j f d 6    j |  j  d | f    f d     Y} |   j   d  S(   Ni(   t   BaseApplications   unix:R  s   %s:%dt   GunicornApplicationc             s&   e  Z   f d    Z  f d   Z RS(   c           s4   x-   j    D] \ } } |  j j | |  q Wd  S(   N(   R@  R,  Rw   (   R~   R|   R   (   R
  (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c           s     S(   N(    (   R~   (   R[  (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRu    s    (   R   R   R  Ru  (    (   R
  R[  (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   (   t   gunicorn.app.baseR  R
  R   R  R2  R^  Rl  (   R~   R[  R  R  (    (   R
  R[  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl  |  s    (   R   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  y  s   t   EventletServerc           B  s   e  Z d  Z d   Z RS(   sN   Untested. Options:

        * `backlog` adjust the eventlet backlog parameter which is the maximum
          number of queued connections. Should be at least 1; the maximum
          value is system-dependent.
        * `family`: (default is 2) socket family, optional. See socket
          documentation for available families.
    c   	      C  s   d d l  m } m } m } | j t  s@ d } t |   n  i  } x< d D]4 } y |  j j |  | | <WqM t	 k
 r qM XqM W|  j
 |  j f } y' | j | | |  | d |  j Wn' t k
 r | j | |  |  n Xd  S(   Ni(   R  R  t   patchers7   Bottle requires eventlet.monkey_patch() (before import)t   backlogt   familyt
   log_output(   R  R  (   R   R  R  R  t   is_monkey_patchedR  R  R^  R   R   R
  R  R   R\  Rh  (	   R~   R[  R  R  R  R   t   socket_argsRN  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s     (   R   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t   BjoernServerc           B  s   e  Z d  Z d   Z RS(   s?    Fast server written in C: https://github.com/jonashaag/bjoern c         C  s0   d d l  m } | | |  j |  j d t d  S(   Ni(   Rl  t
   reuse_port(   t   bjoernRl  R
  R  R   (   R~   R[  Rl  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    (   R   R   R   Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t   AsyncioServerAdapterc           B  s   e  Z d  Z d   Z RS(   s3    Extend ServerAdapter for adding custom event loop c         C  s   d  S(   N(    (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   get_event_loop  s    (   R   R   R   R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t   AiohttpServerc           B  s    e  Z d  Z d   Z d   Z RS(   s    Asynchronous HTTP client/server framework for asyncio
        https://pypi.python.org/pypi/aiohttp/
        https://pypi.org/project/aiohttp-wsgi/
    c         C  s   d d  l  } | j   S(   Ni(   t   asynciot   new_event_loop(   R~   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c           s   d d  l  } d d l m }   j     _ | j   j  d t j k ru d d  l } | j | j	   f d    n  | | d   j
 d   j d  S(   Ni(   R  R  c           s     j  j   S(   N(   t   loopR  (   RF   R   (   R~   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG     RH   R
  R  (   R  t   aiohttp_wsgi.wsgiR  R  R  t   set_event_loopR  R   R  R  R
  R  (   R~   R[  R  R  R  (    (   R~   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s    (   R   R   R   R  Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   	t   AiohttpUVLoopServerc           B  s   e  Z d  Z d   Z RS(   s7   uvloop
       https://github.com/MagicStack/uvloop
    c         C  s   d d  l  } | j   S(   Ni(   t   uvloopR  (   R~   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    (   R   R   R   R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t
   AutoServerc           B  s/   e  Z d  Z e e e e e e g Z	 d   Z
 RS(   s    Untested. c         C  sR   xK |  j  D]@ } y& | |  j |  j |  j  j |  SWq
 t k
 rI q
 Xq
 Wd  S(   N(   t   adaptersR
  R  R^  Rl  t   ImportError(   R~   R[  t   sa(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s
    &(   R   R   R   R  R  R  R|  R  Rg  R  Rl  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   R  Rf  R   R  R  R  R  t   fapws3R  t   gaet   twistedt   dieselR  t   gunicornR   R   R  t   aiohttpR  t   autoc         K  s   d |  k r |  j  d d  n	 |  d f \ } }  | t j k rL t |  n  |  s] t j | S|  j   r} t t j | |   S| j  d  d } t j | | | <t d | |  f |  S(   s   Import a module or fetch an object from a module.

        * ``package.module`` returns `module` as a module object.
        * ``pack.mod:name`` returns the module variable `name` from `pack.mod`.
        * ``pack.mod:func()`` calls `pack.mod.func()` and returns the result.

        The last form accepts not only function calls, but any type of
        expression. Keyword arguments passed to this function are available as
        local variables. Example: ``import_string('re:compile(x)', x='[a-z]')``
    R  i   R  i    s   %s.%sN(   R[  RW   R`   R  R  t   isalnumR   t   eval(   R   R  R  t   package_name(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRu    s    0   c         C  sX   t  t a } t j   } z$ t |   } t |  r8 | S| SWd t j |  | a Xd S(   s    Load a bottle application from a module and make sure that the import
        does not affect the current default application, but returns a separate
        application object. See :func:`load` for the target parameter. N(   R   t   NORUNR  R  Ru  Rg  RD  (   R   t   nr_oldR  Rz  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   load_app  s    s	   127.0.0.1i  c
         K  sT  t  r
 d S| rt j j d  rd d l } t j d d d d  \ } } t j j   } d | d <| | d	 <t j	 g t j
 } t t j j d
  d d  r d t j d
 j g | d d +n  z y t j |  x t j j |  r\| j | d | } x3 | j   d k r3t j | d  t j |  qW| j d k rIq n  t j | j  q WWn t k
 rqn XWd t j j |  rt j |  n  Xd Sy>| d k	 rt |  n  |  pt   }  t |  t  rt |   }  n  t  |   st! d |    n  x? | pg  D]1 } t | t  r6t" |  } n  |  j# |  qW|	 r`|  j$ j% |	  n  | t& k r~t& j |  } n  t | t  rt" |  } n  t | t'  r| d | d | |
  } n  t | t(  st! d |   n  | j) p| | _) | j) sjt* d t+ t, |  f  | j- j. d  rCt* d | j-  n t* d | j- | j/ f  t* d  n  | rt j j d	  } t0 | |  } |  | j1 |   Wd QX| j2 d k rt j d  qn | j1 |   Wnr t k
 rnb t3 t4 f k
 r  nI | s  n  t | d |  s2t5   n  t j |  t j d  n Xd S(   s   Start a server instance. This method blocks until the server terminates.

        :param app: WSGI application or target string supported by
               :func:`load_app`. (default: :func:`default_app`)
        :param server: Server adapter to use. See :data:`server_names` keys
               for valid names or pass a :class:`ServerAdapter` subclass.
               (default: `wsgiref`)
        :param host: Server address to bind to. Pass ``0.0.0.0`` to listens on
               all interfaces including the external one. (default: 127.0.0.1)
        :param port: Server port to bind to. Values below 1024 require root
               privileges. (default: 8080)
        :param reloader: Start auto-reloading server? (default: False)
        :param interval: Auto-reloader interval in seconds (default: 1)
        :param quiet: Suppress output to stdout and stderr? (default: False)
        :param options: Options passed to the server adapter.
     NR  iR   s   bottle.t   suffixs   .lockt   truet   BOTTLE_LOCKFILER%   t   __package__s   -mi   R	  i   s   Application is not callable: %rR
  R  s!   Unknown or unsupported server: %rs+   Bottle v%s server starting up (using %s)...s   unix:s   Listening on %ss   Listening on http://%s:%d/s   Hit Ctrl-C to quit.
t   reloadR\  (6   R  R  R   R   t
   subprocesst   tempfilet   mkstempR#  R`   t
   executablet   argvR   R  RW   R  Ri  R   R  t   Popent   pollt   utimeR  t   sleept
   returncodet   exitR  t   unlinkt   _debugR  RT   Rt  R  Rg  R   Ru  R9  R
  R2  t   server_namesR  RZ  R\  Rd   t   __version__R   R
  R   R  t   FileCheckerThreadRl  RI  R  R  R,   (   R   R   R
  R  t   intervalt   reloaderR\  R  R%  R
  Rp  R  t   fdt   lockfileR   R   R   R  t   bgcheck(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl  )  s     

   	 
R  c           B  s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   sx    Interrupt main-thread as soon as a changed module file is detected,
        the lockfile gets deleted or gets too old. c         C  s9   t  j j |   t |  _ | | |  _ |  _ d  |  _ d  S(   N(	   Ro  t   ThreadR   R   t   daemonR  R  RW   RI  (   R~   R  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    	c         C  sa  t  j j } d   } t   } xw t t j j    D]` } t | d d  pO d } | d d k ro | d  } n  | r4 | |  r4 | |  | | <q4 q4 Wx |  j	 s\| |  j
  s | |  j
  t j   |  j d k  r d	 |  _	 t j   n  xV t | j    D]B \ } } | |  s.| |  | k rd
 |  _	 t j   PqqWt j |  j  q Wd  S(   Nc         S  s   t  j |   j S(   N(   R  R  R  (   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG     RH   R  RH   is   .pyos   .pycii   R   R  (   s   .pyos   .pyc(   R  R   R  Rx   Rv   R`   R  R  R   RI  R  R  R  t   threadt   interrupt_mainR@  R  (   R~   R  t   mtimeR  R  R   t   lmtime(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl    s(    		  &		
c         C  s   |  j    d  S(   N(   R   (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         G  s8   |  j  s d |  _  n  |  j   | d  k	 o7 t | t  S(   NR  (   RI  R   RW   RB  R  (   R~   R  R"   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    	 
(   R   R   R   R   Rl  R  R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s
   			t   TemplateErrorc           B  s   e  Z RS(    (   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   t   BaseTemplatec           B  st   e  Z d  Z d d d d g Z i  Z i  Z d d d d d  Z e d d   Z	 e d    Z
 d	   Z d
   Z RS(   s2    Base class and minimal API for template adapters R  t   htmlt   thtmlt   stplRS   c         K  s7  | |  _  t | d  r$ | j   n | |  _ t | d  rE | j n d |  _ | ry g  | D] } t j j |  ^ q[ n g  |  _	 | |  _
 |  j j   |  _ |  j j |  |  j r |  j  r |  j |  j  |  j	  |  _ |  j s t d t |    q n  |  j r#|  j r#t d   n  |  j |  j   d S(   s=   Create a new template.
        If the source parameter (str or buffer) is missing, the name argument
        is used to guess a template filename. Subclasses can assume that
        self.source and/or self.filename are set. Both are strings.
        The lookup, encoding and settings parameters are stored as instance
        variables.
        The lookup parameter stores a list containing directory paths.
        The encoding parameter should be used to decode byte strings or files.
        The settings parameter contains a dict for engine-specific settings.
        R  R  s   Template %s not found.s   No template specified.N(   R   RJ   R  R  R  RW   R  R   R  R  R5   t   settingsR#  R2  R  R  R   R  (   R~   R  R   R  R5   R  RK   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    	$!4		c         C  s   | s t  d d d d   n  t j j |  rH t  d d d d   n  x | D] } t j j |  t j } t j j t j j | |   } | j |  s qO n  t j j |  r | Sx; |  j	 D]0 } t j j d | | f  r d | | f Sq WqO Wd S(	   s{    Search name in all directories specified in lookup.
        First without, then with common extensions. Return first hit. i    i   s   Empty template lookup path.s!   Configure a template lookup path.s'   Use of absolute path for template name.sC   Refer to templates with names or paths relative to the lookup path.s   %s.%sN(
   Rt   R  R   t   isabsR  R  R   R   R  t
   extensions(   R   R   R  t   spathR  t   ext(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    !  c         G  s;   | r, |  j  j   |  _  | d |  j  | <n |  j  | Sd S(   sB    This reads or sets the global settings stored in class.settings. i    N(   R  R#  (   R   R|   R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   global_config  s    c         K  s
   t   d S(   s    Run preparations (parsing, caching, ...).
        It should be possible to call this again to refresh a template or to
        update settings.
        N(   t   NotImplementedError(   R~   R^  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    c         O  s
   t   d S(   sF   Render the template with the specified local variables and return
        a single byte or unicode string. If it is a byte string, the encoding
        must match self.encoding. This method must be thread-safe!
        Local variables may be provided in dictionaries (args)
        or directly, as keywords (kwargs).
        N(   R"  (   R~   R   RB   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   render  s    N(   R   R   R   R  R  t   defaultsRW   R   t   classmethodR  R!  R  R#  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s   		t   MakoTemplatec           B  s   e  Z d    Z d   Z RS(   c         K  s   d d l  m } d d l m } | j i |  j d 6 | j d t t   | d |  j	 |  } |  j
 r | |  j
 d | | |  _ n' | d |  j d	 |  j d | |  |  _ d  S(
   Ni(   t   Template(   t   TemplateLookupR  t   format_exceptionst   directoriesR  t   uriR  (   t   mako.templateR'  t   mako.lookupR(  R2  R5   R   R+  Rk   R  R  R  R   R  (   R~   R^  R'  R(  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    		c         O  sJ   x | D] } | j  |  q W|  j j   } | j  |  |  j j |   S(   N(   R2  R$  R#  R  R#  (   R~   R   RB   t   dictargt	   _defaults(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR#  ,  s
    (   R   R   R  R#  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR&    s   	t   CheetahTemplatec           B  s   e  Z d    Z d   Z RS(   c         K  s~   d d l  m } t j   |  _ i  |  j _ |  j j g | d <|  j rb | d |  j |  |  _ n | d |  j |  |  _ d  S(   Ni(   R'  t
   searchListR  R^   (	   t   Cheetah.TemplateR'  Ro  Rp  t   contextt   varsR  R  R  (   R~   R^  R'  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  5  s    	c         O  sj   x | D] } | j  |  q W|  j j j  |  j  |  j j j  |  t |  j  } |  j j j   | S(   N(   R2  R3  R4  R$  R   R  R  (   R~   R   RB   R.  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR#  ?  s    (   R   R   R  R#  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR0  4  s   	
t   Jinja2Templatec           B  s,   e  Z d d i  d   Z d   Z d   Z RS(   c         K  s   d d l  m } m } | d | |  j  |  |  _ | rP |  j j j |  n  | rl |  j j j |  n  | r |  j j j |  n  |  j	 r |  j j
 |  j	  |  _ n |  j j |  j  |  _ d  S(   Ni(   t   Environmentt   FunctionLoadert   loader(   t   jinja2R6  R7  R8  R	  R   R2  t   testst   globalsR  t   from_stringR  t   get_templateR   (   R~   R   R:  R;  RB   R6  R7  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  J  s       	c         O  sJ   x | D] } | j  |  q W|  j j   } | j  |  |  j j |   S(   N(   R2  R$  R#  R  R#  (   R~   R   RB   R.  R/  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR#  U  s
    c         C  su   | |  j  k r | } n |  j | |  j  } | s7 d  St | d  ) } | j   j |  j  | d   f SWd  QXd  S(   NR  c           S  s   t  S(   N(   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   c  RH   (   R  R  R  R  R  R\   R5   (   R~   R   R  R   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR8  \  s    	 N(   R   R   RW   R  R#  R8  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR5  I  s   	t   SimpleTemplatec           B  sb   e  Z e e d d   Z e d    Z e d    Z d d  Z	 d d  Z
 d   Z d   Z RS(   c           sh   i  |  _  |  j     f d   |  _    f d   |  _ | |  _ | rd |  j |  j |  _ |  _ n  d  S(   Nc           s   t  |     S(   N(   RE   (   RK   (   RY   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   m  RH   c           s    t  |      S(   N(   RE   (   RK   (   RY   t   escape_func(    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG   n  RH   (   R  R5   t   _strt   _escapet   syntax(   R~   R?  t   noescapeRB  Ri   (    (   RY   R?  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  g  s    			c         C  s   t  |  j |  j p d d  S(   Ns   <string>RR   (   R   R  R  (   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   cos  s    c         C  s   |  j  } | s9 t |  j d   } | j   } Wd  QXn  y t |  d } } Wn& t k
 rx t d d d d   n Xt | d | d |  j } | j	   } | j
 |  _
 | S(	   NR  RS   i    i   s   Unsupported template encodings.s   Use utf-8 for templates.R5   RB  (   R  R  R  R  RE   R  Rt   t
   StplParserRB  t	   translateR5   (   R~   R  R   R5   R   R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  w  s    	c         K  s   | | f | d <d  S(   Nt   _rebase(    (   R~   t   _envR   RB   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRG    s    c         K  sq   | j    } | j |  | |  j k rV |  j d | d |  j d |  j  |  j | <n  |  j | j | d |  S(   NR   R  RB  t   _stdout(   R#  R2  R  R*  R  RB  t   execute(   R~   RH  R   RB   R	  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _include  s
    .c         B  s   |  j  j   } | j |  | j i
 | d 6| j d 6e j |  j |  d 6e j |  j |  d 6d  d 6|  j	 d 6|  j
 d 6| j d 6| j d	 6| j d
 6 |  j | U| j d  r | j d  \ } } d j |  | d <| 2|  j | | |  S| S(   NRI  t
   _printlistt   includet   rebaseRG  R@  RA  R   R   t   definedRH   R  (   R$  R#  R2  t   extendRe   R0  RK  RG  RW   R@  RA  R   R   RL  RD  R   R   (   R~   RI  RB   R	  t   subtplt   rargs(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRJ    s(    	




c         O  sT   i  } g  } x | D] } | j  |  q W| j  |  |  j | |  d j |  S(   sA    Render the template using keyword arguments as local variables. RH   (   R2  RJ  R   (   R~   R   RB   R	  t   stdoutR.  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR#    s    N(   R   R   R  R   RW   R  R   RD  R  RG  RK  RJ  R#  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR>  f  s   		t   StplSyntaxErrorc           B  s   e  Z RS(    (   R   R   (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRT    s   RE  c           B  s   e  Z d  Z i  Z d Z e j d d  Z e d 7Z d Z d e Z d e Z d e Z d Z d d	 d
  Z
 d   Z d   Z e e e  Z d   Z d   Z d   Z e d    Z d d  Z RS(   s    Parser for stpl templates. s  (
        [urbURB]*
        (?:  ''(?!')
            |""(?!")
            |'{6}
            |"{6}
            |'(?:[^\\']|\\.)+?'
            |"(?:[^\\"]|\\.)+?"
            |'{3}(?:[^\\]|\\.|\n)+?'{3}
            |"{3}(?:[^\\]|\\.|\n)+?"{3}
        )
    )s   |\nRH   s  
        # 2: Comments (until end of line, but not the newline itself)
        |(\#.*)

        # 3: Open and close (4) grouping tokens
        |([\[\{\(])
        |([\]\}\)])

        # 5,6: Keywords that start or continue a python block (only start of line)
        |^([\ \t]*(?:if|for|while|with|try|def|class)\b)
        |^([\ \t]*(?:elif|else|except|finally)\b)

        # 7: Our special 'end' keyword (but only if it stands alone)
        |((?:^|;)[\ \t]*end[\ \t]*(?=(?:%(block_close)s[\ \t]*)?\r?$|;|\#))

        # 8: A customizable end-of-code-block template token (only end of line)
        |(%(block_close)s[\ \t]*(?=\r?$))

        # 9: And finally, a single newline. The 10th token is 'everything else'
        |(\r?\n)
    s4   (?m)^[ \t]*(\\?)((%(line_start)s)|(%(block_start)s))s2   %%(inline_start)s((?:%s|[^'"\n])*?)%%(inline_end)ss   (?mx)s   <% %> % {{ }}RS   c         C  sv   t  | |  | |  _ |  _ |  j | p. |  j  g  g  |  _ |  _ d \ |  _ |  _ d \ |  _	 |  _
 d |  _ d  S(   Ni   i    (   i   i    (   i    i    (   RE   R  R5   t
   set_syntaxt   default_syntaxt   code_buffert   text_buffert   linenoR   t   indentt
   indent_modt   paren_depth(   R~   R  RB  R5   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR     s    c         C  s   |  j  S(   s=    Tokens as a space separated string (default: <% %> % {{ }}) (   t   _syntax(   R~   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   get_syntax  s    c         C  s   | |  _  | j   |  _ | |  j k r d } t t j |  j  } t t | j   |   } |  j	 |  j
 |  j f } g  | D] } t j | |  ^ q| } | |  j | <n  |  j | \ |  _ |  _ |  _ d  S(   Ns:   block_start block_close line_start inline_start inline_end(   R]  R[  t   _tokenst	   _re_cacheR  R   R   Rx   RC  t	   _re_splitt   _re_tokt   _re_inlR   t   re_splitt   re_tokt   re_inl(   R~   RB  R  t   etokenst   pattern_varst   patternsR   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRU    s    	&c         C  s  |  j  r t d   n  x9t rS|  j j |  j d |  j  } | rO|  j |  j  | j   !} |  j j |  | j	   |  _  | j
 d  r|  j |  j  j d  \ } } } |  j j |  j | j   | j d  !| j
 d  | |  |  j  t | |  7_  q n  |  j   |  j  |  j |  j |  j  d t | j
 d   7_  q Pq W|  j j |  j |  j   |  j   d j |  j  S(	   Ns   Parser is a one time instance.t   posi   s   
i   t	   multilinei   RH   (   R   R  R   Rd  R  R  R   RX  R   R   R   R  R   t
   flush_textt	   read_codeR+  R   RW  (   R~   R   Rs   t   lineR  R"   (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRF  	  s*    	 	"	5

c      	   C  sh  d \ } } d } xOt  rc|  j j | d | } | sm | | | 7} t |  } |  j | j   |  Pn  | | | | j   !7} | j   } | j   \	 } } }	 }
 } } } } } |  j	 d k r | s | r | | p | 7} q n  | r | | 7} q | r5| } | r`| j   j
 |  j d  r`t } q`q |	 rW|  j	 d 7_	 | |	 7} q |
 r|  j	 d k r~|  j	 d 8_	 n  | |
 7} q | r| } |  j d 7_ |  j d 8_ q | r| } |  j d 8_ q | r| rt } q`| | 7} q | r|  j d 8_ |  j d 7_ q |  j | j   |  |  j d 7_ d \ } } |  _ | s Pq q W| S(   NRH   i    Rj  i   (   RH   RH   (   RH   RH   i    (   R   Re  R  R   t
   write_codeRn  R   R   R   R\  R]  R_  R   RZ  R[  RY  (   R~   t   pysourceRk  t	   code_linet   commentR   R   R@  t   _comt   _pot   _pct   _blk1t   _blk2t   _endt   _cendt   _nl(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRm     s`    	'" 	c   	      C  s  d j  |  j  } |  j 2| s# d  Sg  d d d |  j } } } x |  j j |  D] } | | | j   !| j   } } | r | j | j  t t	 | j
 t     n  | j d  r | d c | 7<n  | j |  j | j d  j     qU W| t |  k  r| | } | j
 t  } | d j d  rJ| d d	  | d <n( | d j d
  rr| d d  | d <n  | j | j  t t	 |    n  d d j  |  } |  j | j d  d 7_ |  j |  d  S(   NRH   i    s   \
s     s   
ii   s   \\
is   \\
is   _printlist((%s,))s   , (   R   RX  RZ  Rf  R   R   R   R   R  R   t
   splitlinesR   R]  t   process_inlineR   Rn  R   RY  t   countRo  (	   R~   Rs   R4  Rj  t   nlR   R   t   linesR  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRl  U  s.      + )
  "c         C  s$   |  d d k r d |  d Sd |  S(   Ni    R  s   _str(%s)i   s   _escape(%s)(    (   t   chunk(    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR|  j  s     c         C  s@   d |  j  |  j } | | j   | d 7} |  j j |  d  S(   Ns     s   
(   RZ  R[  Ra  RW  R   (   R~   Rn  Rr  R  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRo  o  s    N(   R   R   R   R`  Rb  R6  Rc  Ra  RV  RW   R   R^  RU  R0  RB  RF  Rm  Rl  R3  R|  Ro  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRE    s(   


				5	c          O  se  |  r |  d n d } x |  d D] } | j |  q! W| j d t  } | j d t  } t |  | f } | t k s t r6| j d i   } t | |  r | t | <| r3t | j	 |   q3q6d | k s d | k s d | k s d	 | k r| d
 | d | |  t | <q6| d | d | |  t | <n  t | sTt
 d d |  n  t | j |  S(   s   
    Get a rendered template as a string iterator.
    You can use a name, a filename or a template string as first parameter.
    Template rendering arguments can be passed as dictionaries
    or directly (as keyword arguments).
    i    i   t   template_adaptert   template_lookupR  s   
t   {t   %t   $R  R  R   i  s   Template (%s) not foundN(   RW   R2  R   R>  t   TEMPLATE_PATHt   idt	   TEMPLATESRk   RT   R  R  R#  (   R   RB   R  R.  t   adapterR  t   tplidR  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR  u  s$    
 0
R  c           s      f d   } | S(   s   Decorator: renders a template for a handler.
        The handler can control its behavior like that:

          - return a dict of template vars to fill out the template
          - return something other than a dict and the view decorator will not
            process the template, but return the handler result as is.
            This includes returning a HTTPResponse(dict) to get,
            for instance, JSON with autojson or other castfilters.
    c           s(   t  j        f d    } | S(   Nc            sg    |  |   } t  | t t f  rJ   j   } | j |  t  |  S| d  k rc t     S| S(   N(   RT   Rx   t	   DictMixinR#  R2  R  RW   (   R   RB   t   resultt   tplvars(   R$  R@   t   tpl_name(    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRg     s    (   Re   R}  (   R@   Rg   (   R$  R  (   R@   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyRH    s    $(    (   R  R$  RH  (    (   R$  R  sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyR    s    s   ./s   ./views/s   I'm a teapoti  s   Precondition Requiredi  s   Too Many Requestsi  s   Request Header Fields Too Largei  s   Unavailable For Legal Reasonsi  s   Network Authentication Requiredi  c         c  s+   |  ]! \ } } | d  | | f f Vq d S(   s   %d %sN(    (   R   RN  RO  (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pys	   <genexpr>  s   s#  
%%try:
    %%from %s import DEBUG, request
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html>
        <head>
            <title>Error: {{e.status}}</title>
            <style type="text/css">
              html {background-color: #eee; font-family: sans-serif;}
              body {background-color: #fff; border: 1px solid #ddd;
                    padding: 15px; margin: 15px;}
              pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
            </style>
        </head>
        <body>
            <h1>Error: {{e.status}}</h1>
            <p>Sorry, the requested URL <tt>{{repr(request.url)}}</tt>
               caused an error:</p>
            <pre>{{e.body}}</pre>
            %%if DEBUG and e.exception:
              <h2>Exception:</h2>
              %%try:
                %%exc = repr(e.exception)
              %%except:
                %%exc = '<unprintable %%s object>' %% type(e.exception).__name__
              %%end
              <pre>{{exc}}</pre>
            %%end
            %%if DEBUG and e.traceback:
              <h2>Traceback:</h2>
              <pre>{{e.traceback}}</pre>
            %%end
        </body>
    </html>
%%except ImportError:
    <b>ImportError:</b> Could not generate the error page. Please add bottle to
    the import path.
%%end
s
   bottle.exts   .exts	   bottle_%sc           sx  t  |   \ }     f d   } | j rH t d t  t j d  n  | j s^ | d  n  t j j d d  t j	 j
 d t j	 d  | j p d d	 } } d
 | k r | j d  | j d
  k  r | j d
 d  \ } } n  | j d  } t   } x | j pg  D] } yT | j d  rZt | d    } | j t | j     Wd  QXn | j |  Wqt j k
 r} | |  qt k
 r| d |  qt t t f k
 r}	 | d | |	 f  qXqWxL | j pg  D]; }
 d |
 k r| j |
 j d d  f  qt  | |
 <qWt! | j d | d t" |  d | j# d | j$ d | j% d | j& d | d  S(   Nc           s)     j    t d |   t j d  d  S(   Ns   
Error: %s
i   (   t
   print_helpRd   R`   R  (   t   cli_msg(   R   (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt
   _cli_error  s    
s	   Bottle %si    s%   No application entry point specified.R  R  R%   t	   localhosti  R  t   ]i   s   []s   .jsonR  s   Unable to read config file %rs"   Unable to parse config file %r: %sR2  R
  R  R   R  R  R%  R
  ('   R   t   versionR_   R
  R`   R  R   R   RB  R  R   R  t   rfindR  Rn  R)  R   R]  R  R  R  R  R  R  t   ErrorRb   R  Rh  R   t   paramR2  R[  R   Rl  R   R   R  R  R%  (   R   R   R  R
  R  R
  t   cfileR  t   parse_errorR   t   cval(    (   R   sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   _main
  sL    		*	"				(   R   t
   __future__R    R`   t
   __author__R
  t   __license__R   R$   R   R   R  R)  R  t   email.utilsR  Re   R  RU  R	  R  R   R  Ro  R  Rm   R  R1  t   typesR&   R(   R'   R'  R)   R*   R  R+   R,   t   unicodedataR-   t   ujsonR.   Rx  R/   RD   R  R  t   version_infoRc  Ro   R  t   http.clientt   clientt   httplibt   _threadR  t   urllib.parseR0   R1   R  R2   R3   R  R4   R=  R0  t   http.cookiesR7   R8   R9   t   collections.abcR:   R  R;   RP   R  t   ioR<   R  t   inspectR=   RC   R   Rt  RU   R  Rg  R  RO   RN   t   urlparset   urllibt   Cookiet   cPicklet   impRQ   R  t   collectionsR   RZ   RE   R  Rd   Rf   Rt   R>   R-  Rz   R   R   R  R   R   R   R   R   R   R   R   R  R&  R  R7  R8  R9  R<  Rq  Rr  Rs  R"  t   ResponseRT  R   Rw  R:  R;  R  R  R  RJ  R  R  Rx   R)  Rv   R  R  R  R4  R  R  RW   R  R  R   R   R#  R%  RX  RW  R  R  t   findallR3  R:  R  R  RD  RG  RE  R  RL  Rv  RS  RX  RY  R\  R   Rx  Rz  R|  R~  R   Rd  RG  R9  Rk  R   RZ  R]  Ra  Rg  R|  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R	  Ru  R  R  Rl  R  R  R  R  R&  R0  R5  R>  RT  RE  R  t   mako_templatet   cheetah_templatet   jinja2_templateR  t	   mako_viewt   cheetah_viewt   jinja2_viewR  R  Rk   R  t	   responsesR#  t
   HTTP_CODESR@  RG  R  RR  R  Rp  t   appsR   R  R  R   R  (    (    (    sA   /var/www/10/harkonen/sites/harkonen.kapsi.fi/www/bottle/bottle.pyt   <module>   s  
								
	
					o   		 	
,(g.&;	 VGl					!		
					

!


		h.RL			





	)
			6