Ñò
Õ¥WJc           @   s%  d  Z  d d k Z d d k Z d d k Z d d k Z d d k l Z d d k l Z d d k	 l
 Z
 d d k Z d d k Z d Z e d d d	 d
 d e d d ƒ Z e d d d d d	 d d h d d 6d d 6ƒ Z e i e ƒ Z d e f d „  ƒ  YZ e ƒ  Z e i e i ƒ Z e i e ƒ d S(   sM  Configuration object and defaults setup

The PylonsConfig object is initialized in pylons projects inside the
:file:`config/environment.py` module. Importing the :data:`config`
object from module causes the PylonsConfig object to be created, and
setup in  app-safe manner so that multiple apps being setup avoid
conflicts.

After importing :data:`config`, the project should then call
:meth:`~PylonsConfig.init_app` with the appropriate options to setup
the configuration. In the config data passed with
:meth:`~PylonsConfig.init_app`, various defaults are set use with Paste
and Routes.

iÿÿÿÿN(   t   DispatchingConfig(   t   asbool(   t	   MIMETypest   makot   charsets   utf-8t   errorst   replacet   decode_param_namest   languages   en-ust   content_types	   text/htmlt   strictt   headerss   no-caches   Cache-Controlt   Pragmat   PylonsConfigc        	   B   sú   e  Z d  Z h e d 6d d 6h d d 6d d 6g  d 6d d 6d 6h  d 6e d	 d
 d d ƒ d 6d d 6d d 6e i ƒ  d 6e i ƒ  d 6e d 6e	 d 6g  d 6h  d 6Z
 d „  Z d d d d d e d d d „ Z d d d „ Z d e d d „ Z d „  Z RS(   s  Pylons configuration object

    The Pylons configuration object is a per-application instance
    object that retains the information regarding the global and app
    conf's as well as per-application instance specific data such as
    the mapper, and the paths for this instance.

    The config object is available in your application as the Pylons
    global :data:`pylons.config`. For example::

        from pylons import config

        template_paths = config['pylons.paths']['templates']

    There's several useful keys of the config object most people will
    be interested in:

    ``pylons.template_options``
        Full dict of template options that any TG compatible plugin
        should be able to parse. Comes with basic config needed for
        Genshi, Mako, Myghty, and Kid.
    ``pylons.paths``
        A dict of absolute paths that were defined in the applications
        ``config/environment.py`` module.
    ``pylons.environ_config``
        Dict of environ keys for where in the environ to pickup various
        objects for registering with Pylons. If these are present then
        PylonsApp will use them from environ rather than using default
        middleware from Beaker. Valid keys are: ``session, cache``
    ``pylons.template_engines``
        List of template engines to configure. The first one in the
        list will be configured as the default template engine. Each
        item in the list is a dict indicating how to configure the
        template engine with keys:
        
        ``engine``, ``template_root``, ``template_options``, and 
        ``alias``
    ``pylons.default_charset``
        Deprecated: Use the response_settings dict instead.
        Default character encoding specified to the browser via the
        'charset' parameter of the HTTP response's Content-Type header.
    ``pylons.strict_c``
        Whether or not the ``c`` object should throw an attribute error
        when access is attempted to an attribute that doesn't exist.
    ``pylons.request_options``
        A dict of Content-Type related default settings for new
        instances of :class:`~pylons.controllers.util.Request`. May
        contain the values ``charset`` and ``errors`` and 
        ``decode_param_names``. Overrides the Pylons default values
        specified by the ``request_defaults`` dict.
    ``pylons.response_options``
        A dict of Content-Type related default settings for new 
        instances of :class:`~pylons.controllers.util.Response`. May
        contain the values ``content_type``, ``charset`` and
        ``errors``. Overrides the Pylons default values specified by
        the ``response_defaults`` dict.
    ``routes.map``
        Mapper object used for Routing. Yes, it is possible to add
        routes after your application has started running.
    
    t   debugs   pylons.packaget   roott   controllerst	   templatest   static_filess   pylons.pathss   pylons.db_enginest   sessions   beaker.sessiont   caches   beaker.caches   pylons.environ_configs   pylons.gs   pylons.hs   pylons.request_optionss   pylons.response_optionss   pylons.strict_cs   pylons.c_attach_argss   buffet.template_enginess   buffet.template_optionsc            sÃ   | d j o! d t  f ‡  f d †  ƒ  Y} | Sˆ  i ƒ  } xQ d D]I } | | } | | j o, t i t i i | | f t d ƒ | | SqA W| d	 j o t S| d
 j o t	 St
 | | ƒ Sd  S(   Nt   Configt
   FakeConfigc              s5   e  Z ‡  f d  †  Z ‡  f d †  Z ‡  f d †  Z RS(   c            s   ˆ  i  | | Ž  d  S(   N(   t   load_environment(   t   thist   argst   kwargs(   t   self(    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyt   __init__~   s    c            s   t  ˆ  | ƒ S(   N(   t   getattr(   R   t   name(   R   (    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyt   __getattr__€   s    c            s   t  ˆ  | | ƒ d  S(   N(   t   setattr(   R   R   t   value(   R   (    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyt   __setattr__‚   s    (   t   __name__t
   __module__R   R   R"   (    (   R   (    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyR   }   s   t    s   pylons.s   buffet.s   routes.i   t   request_defaultst   response_defaults(   R%   s   pylons.s   buffet.s   routes.(   t   objectt   current_conft   warningst   warnt   pylonst   legacyt   config_attr_movedt   DeprecationWarningR&   R'   R   (   R   R   R   t	   conf_dictt   prefixt	   full_name(    (   R   sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyR   z   s      
c	   
      C   s  t  i t i i t d ƒ t i t i	 ƒ }	 | o | |	 d <n | o |	 d i
 | ƒ n | o |	 d i
 | ƒ n | d j	 o | |	 d <n | |	 d <| p h  |	 d <| |	 d <| o> t  i t i i t d	 d
 d | ƒ t d ƒ | |	 d d <n |	 |  d <d S(   sg   Load the environment options
        
        Deprecated functionality for pre-0.9.6 projects.
        i   s   buffet.template_optionss   pylons.request_optionss   pylons.response_optionss   pylons.environ_configs
   routes.maps   pylons.pathss   pylons.strict_ct   klassR   R   i   t   environment_loadN(   R*   R+   R,   R-   t   config_load_environmentR/   t   copyt   deepcopyR   t   defaultst   updatet   Nonet   default_charset_warningt   dict(
   R   t   tmpl_optionst   mapt   pathst   environ_configt   default_charsett   strict_ct   request_settingst   response_settingst   conf(    (    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyR   –   s(    



c      	   C   sa   | p |  d } n t  d | d | d | d | ƒ } t i d | | | ƒ |  d i | ƒ d S(	   sù  Add additional template engines for configuration on Pylons
        WSGI init.

        ``engine``
            The name of the template engine

        ``root``
            Template root for the engine

        ``options``
            Dict of additional options used during engine
            initialization, if not provided, default to using the
            template_options dict.

        ``alias``
            Name engine should respond to when actually used. This
            allows for multiple configurations of the same engine and
            lets you alias the additional ones to other names.

        Example of Kid addition:

        .. code-block:: python

            # In yourproj/middleware.py
            # ...
            config.init_app(global_conf, app_conf, package='yourproj')

            # Load additional template engines
            kidopts = {'kid.assume_encoding':'utf-8', 
                       'kid.encoding':'utf-8'}
            config.add_template_engine('kid', 'yourproj.kidtemplates', 
                                       kidopts)

        Example of changing the default template engine:

        .. code-block:: python

            # In yourproj/middleware.py
            # ...
            config.init_app(global_conf, app_conf, package='yourproj')

            # Remove existing template engine
            old_default = config.template_engines.pop()

            # Load additional template engines
            kidopts = {'kid.assume_encoding':'utf-8', 
                       'kid.encoding':'utf-8'}
            config.add_template_engine('kid', 'yourproj.kidtemplates', 
                                       kidopts)

            # Add old default as additional engine
            config.template_engines.append(old_default)
        
        s   buffet.template_optionst   enginet   template_roott   template_optionst   aliass-   Adding %s engine with alias %s and %s optionss   buffet.template_enginesN(   R<   t   logR   t   append(   R   RF   R   t   optionsRI   t   config(    (    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyt   add_template_engine¹   s    7
c         C   s   t  i d | ƒ | i ƒ  } | i | ƒ | i t d | d | ƒ ƒ | i |  i d h  ƒ ƒ | o | | d <n | | d <| d <| d d <d | j o t | d ƒ | d <n | o8 d	 | j o+ t i t	 i
 i t d
 ƒ | d	 | d <n t  i d ƒ |  i | ƒ |  i | ƒ d S(   s­  Initialize configuration for the application
        
        .. note
            This *must* be called at least once, as soon as possible 
            tosetup all the configuration options.
        
        ``global_conf``
            Several options are expected to be set for a Pylons web
            application. They will be loaded from the global_config 
            which has the main Paste options. If ``debug`` is not 
            enabled as a global config option, the following option
            *must* be set:

            * error_to - The email address to send the debug error to

            The optional config options in this case are:

            * smtp_server - The SMTP server to use, defaults to 
              'localhost'
            * error_log - A logfile to write the error to
            * error_subject_prefix - The prefix of the error email
              subject
            * from_address - Whom the error email should be from
        ``app_conf``
            Defaults supplied via the [app:main] section from the Paste
            config file. ``load_config`` only cares about whether a 
            'prefix' option is set, if so it will update Routes to
            ensure URL's take that into account.
        ``package``
            The name of the application package, to be stored in the 
            app_conf.
        
        .. versionchanged:: 0.9.7
            ``template_engine`` is no longer required, and can be set
            to :data:`None` to avoid loading the default one.
        
        ``template_engine``
            Declare the default template engine to setup. Choices are
            kid, genshi, mako (the default), and pylonsmyghty.
        
        s)   Initializing configuration, package: '%s't   app_conft   global_confR4   s   pylons.pathss   pylons.packaget   packageR   t	   root_pathi   R   s   Pushing process configurationN(   RJ   R   R6   R9   R<   t   popR   R*   R+   R,   R-   RR   R/   t   push_process_configt   set_defaults(   R   RP   RO   RQ   t   template_engineR?   RE   (    (    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyt   init_appø   s     +c         C   sù  |  i  ƒ  } t i ƒ  x6 t i t i ƒ i ƒ  D] \ } } | i | | ƒ q/ W| i	 d ƒ } | oM t
 i t i i | t d ƒ | i	 d ƒ } | o | | _ t | _ q² n h  } t | i	 d ƒ ƒ | d <| d p› t | d <| i	 d ƒ | d <| i	 d d  ƒ | d <| i	 d d	 ƒ | d <| i	 d
 d ƒ | d
 <| i	 d | i	 d d ƒ ƒ | d <| i	 d d ƒ | d <n h  } t | d <| d d | d <g  }	 | d d D]  }
 |	 h |
 t i i |
 ƒ 6q¬~	 | d <| i d g  ƒ i t i i ƒ h  } d | j o% t
 i d t d ƒ | d | d <n/ d | j o! t i i | d d ƒ | d <n d | j oJ | i d t i i | d d ƒ ƒ | i d t i i | d d  ƒ ƒ n xV | i ƒ  D]H \ } } | | d! | <| i d" ƒ p | i d# ƒ o | | | <qÂqÂWxf | i ƒ  D]X \ } } | i d# ƒ o | | d$ | d% <q| i d" ƒ o | | d& | d' <qqW| d( i | ƒ h  } | d d | d) <t | d* <| d d | d+ <d | j o! t i i | d d ƒ | d, <n d- | d. <| d d | d/ <| i | d( ƒ | | d( <| d0 j o |  i  d0 d  | ƒ nt | d1 j o |  i  d1 d2 ƒ nS | d= j o |  i  | | d5 d6 ƒ n* | d7 j o |  i  | d8 | d5 ƒ n t! i" d9 | ƒ | i# d | d: i	 d ƒ ƒ | d; <| | d< <d  S(>   NR1   i   s
   routes.mapR   t   email_tot   error_emailt	   error_logt   smtp_servert	   localhostt   error_subject_prefixs   WebApp Error: t   from_addresst   error_email_froms   pylons@yourapp.comt   error_messages!   An internal server error occurredt   raise_errors   pylons.response_optionsR   t   output_encodings   pylons.pathsR   t   component_roott   allow_globalst   myghty_data_dirsU   Old config option found in ini file, replace 'myghty_data_dir' option with 'data_dir't   data_dirt	   cache_dirs   beaker.session.data_dirt   sessionss   beaker.cache.data_dirR   s   myghty.t   session_t   cache_s   cache.i   s   session.i   s   buffet.template_optionss   mako.directoriess   mako.filesystem_checkss   mako.output_encodings   mako.module_directorys   utf-8s   kid.assume_encodings   kid.encodingt   pylonsmyghtyR   R%   t   genshit   kids   pylons.packages
   .templatest   cheetahs   %s.templatess:   Loaded %s template engine as the default template rendererRO   s   pylons.cache_dirs   pylons.errorware(   s   genshis   kid($   R)   R   t   initR6   R7   R   R8   t	   iteritemst
   setdefaultt   getR*   R+   R,   R-   t   prefix_warningR/   R1   t   Falset   _created_regsR   R:   t   Truet   ost   patht   basenamet   extendt
   templatingt   PYLONS_VARSt   joint
   startswitht   itemsR9   RN   RJ   R   RS   (   R   RV   RE   t   keyt   valR1   R>   t	   errorwaret   myghty_defaultst   _[1]Rx   t   myghty_template_optionst   kt   vR8   (    (    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyRU   <  s¬    
 
	
		
9		
		   
!

			N(   R#   R$   t   __doc__Rt   R:   R<   R&   R6   R'   Rv   R8   R   R   RN   t   default_template_engineRW   RU   (    (    (    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyR   (   s8   =


		 ?C(   Rˆ   R6   t   loggingRw   R*   t   paste.configR    t   paste.deploy.convertersR   t   webhelpers.mimehelperR   t   pylons.legacyR,   t   pylons.templatingR‰   R<   Rt   R&   R'   t	   getLoggerR#   RJ   R   RM   R7   R8   t   initial_configRT   (    (    (    sm   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/configuration.pyt   <module>   s,   
ÿ —	