Ñò
Õ¥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
 l Z d d k l Z d d k Z d d k Z d d k Z d d d	 d
 d g Z e i e ƒ Z d d „ Z d „  Z e e i i e d ƒ ƒ Z e e i i e d ƒ ƒ Z e e i i e d ƒ ƒ Z d „  Z e d „ Z e d „ Z d „  Z  d	 e! f d „  ƒ  YZ" d e! f d „  ƒ  YZ# d e# f d „  ƒ  YZ$ d e
 f d „  ƒ  YZ% d e% f d „  ƒ  YZ& d e f d „  ƒ  YZ' d S(   s™  Paste Template and Pylons utility functions

PylonsTemplate is a Paste Template sub-class that configures the source
directory and default plug-ins for a new Pylons project. The minimal
template a more minimal template with less additional directories and
layout.

The functions used in this module are to assist Pylons in creating new
projects, and handling deprecation warnings for moved Pylons functions.

iÿÿÿÿN(   t   asbool(   t	   Installer(   t   Templatet   var(   t   paste_script_template_renderert   AttribSafeContextObjt
   ContextObjt   PylonsContextt   class_name_from_module_namet   call_wsgi_applications   pylons.i18nc         C   s   d |  | f S(   NsY   The %s function has moved to %s, please update your import statements to reflect the move(    (   t   namet   moved_to(    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyt	   func_move   s    c            sR   ‡ ‡  f d †  } y ˆ i  | _  Wn t j
 o n Xd ˆ  ˆ i f | _ | S(   Nc             s    t  i ˆ t d ƒ ˆ  |  | Ž  S(   Ni   (   t   warningst   warnt   DeprecationWarning(   t   argst   kargs(   t   funct   message(    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyt   deprecated_method%   s    s   %s

%s(   t   __name__t	   TypeErrort   __doc__(   R   R   R   (    (   R   R   sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyt
   deprecated$   s    t   get_langt   set_langt   _c          O   s   d d k  } | i i |  | Ž  S(   sV   Deprecated: Use the logging module instead.

    Log a message to the output log.
    iÿÿÿÿN(   t   pylons.helperst   helperst   log(   R   t   kwargst   pylons(    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyR   5   s    c         C   si   | o t  i d t d ƒ n t i i d d ƒ } | p+ |  i d d ƒ d j o |  d } qe n | S(   s6   Deprecated: Use environ.get('SCRIPT_NAME', '') insteadsX   The get_prefix function is deprecated, please use environ.get('SCRIPT_NAME', '') insteadi   t   prefixt    t   SCRIPT_NAME(   R   R   R   R    t   configt   get(   t   environR   R!   (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyt
   get_prefix=   s    	c      	      s¼   g  ‰ g  ‰ d ‡  ‡ ‡ f d † } |  | | ƒ } ˆ p ˆ o= z ˆ i | ƒ Wd t | d ƒ o | i ƒ  n Xˆ } n ˆ  o ˆ d ˆ d | ˆ d f Sˆ d ˆ d | f Sd S(   s±  
    Call the given WSGI application, returning ``(status_string,
    headerlist, app_iter)``

    Be sure to call ``app_iter.close()`` if it's there.

    If catch_exc_info is true, then returns ``(status_string,
    headerlist, app_iter, exc_info)``, where the fourth item may
    be None, but won't be if there was an exception.  If you don't
    do this and there was an exception, the exception will be
    raised directly.
    c            sH   | d  j	 o$ ˆ  o | d | d | d ‚ n |  | | g ˆ (ˆ i S(   Ni    i   i   (   t   Nonet   append(   t   statust   headerst   exc_info(   t   catch_exc_infot   outputt   captured(    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyt   start_responseY   s    Nt   closei    i   i   (   R(   t   extendt   hasattrR1   (   t   applicationR&   R-   R0   t   app_iter(    (   R-   R.   R/   sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyR	   J   s    
c         C   sI   |  i  d d ƒ i d ƒ } d i g  } | D] } | | i ƒ  q, ~ ƒ S(   s“  Takes a module name and returns the name of the class it
    defines.

    If the module name contains dashes, they are replaced with
    underscores.

    Example::

        >>> class_name_from_module_name('with-dashes')
        'WithDashes'
        >>> class_name_from_module_name('with_underscores')
        'WithUnderscores'
        >>> class_name_from_module_name('oneword')
        'Oneword'

    t   -R   R"   (   t   replacet   splitt   joint   title(   t   module_namet   wordst   _[1]t   w(    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyR   l   s    c           B   s   e  Z d  Z RS(   s
  Pylons context object
    
    All the Pylons Stacked Object Proxies are also stored here, for use
    in generators and async based operation where the globals can't be
    used.
    
    This object is attached in
    :class:`~pylons.controllers.core.WSGIController` instances as
    :attr:`~WSGIController._py_object`. For example::

        class MyController(WSGIController):
            def index(self):
                pyobj = self._py_object
                return "Environ is %s" % pyobj.request.environ
    
    (   R   t
   __module__R   (    (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyR      s   c           B   s   e  Z d  Z d „  Z RS(   sy   The :term:`tmpl_context` object, with strict attribute access
    (raises an Exception when the attribute does not exist)c      
   C   sö   g  } |  i  i ƒ  D]- \ } } | i d ƒ p | | | f q q ~ } | i ƒ  g  } xd | D]\ \ } } t | ƒ } t | ƒ d j o | d  d | d } n | i d | | f ƒ qa Wd |  i i |  i i	 t
 t |  ƒ ƒ d i | ƒ f S(	   NR   iF   i<   s   ...iûÿÿÿs    %s=%ss   <%s.%s at %s%s>t   ,(   t   __dict__t   itemst
   startswitht   sortt   reprt   lenR)   t	   __class__R?   R   t   hext   idR9   (   t   selfR=   R
   t   valuet   attrst   partst
   value_repr(    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyt   __repr__˜   s     *
 		(   R   R?   R   RO   (    (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyR   •   s   c           B   s   e  Z d  Z d „  Z RS(   sn   The :term:`tmpl_context` object, with lax attribute access (
    returns '' when the attribute does not exist)c         C   s?   y t  i |  | ƒ SWn$ t j
 o t i d | ƒ d SXd  S(   Ns@   No attribute called %s found on c object, returning empty stringR"   (   t   objectt   __getattribute__t   AttributeErrort
   pylons_logt   debug(   RJ   R
   (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyt   __getattr__­   s    	(   R   R?   R   RU   (    (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyR   ª   s   t   PylonsTemplatec           B   sq   e  Z d Z e e ƒ Z d Z d d g Z e d d d d ƒe d	 d
 d e	 ƒg Z
 d d d d g Z d „  Z RS(   R    s   templates/default_projects   Pylons application templatet   PasteScriptt   Pylonst   template_engines)   mako/genshi/jinja2/etc: Template languaget   defaultt   makot
   sqlalchemys0   True/False: Include SQLAlchemy 0.5 configurationt   descriptiont   authort   author_emailt   urlc         C   sè   | d } | d j o
 d } n | | d <| i  d t i i ƒ } | d j o d d d f | d <n d | d <x! |  i D] } | i  | d ƒ q| W| i d d ƒ | d <t | i d d ƒ ƒ | d <t | i d d ƒ ƒ | d <d S(   s"   Called before template is applied.t   packaget   roott   appt   package_loggerRY   R[   sA   ('templates/**.mako', 'mako', {'input_encoding': 'utf-8'}),
%s#%st    i   i   t   babel_templates_extractorR"   t   versions   0.1t   zip_safet   falseR\   Ns       s           (   t
   setdefaultR    t   configurationt   default_template_enginet   ensure_namesR%   R    (   RJ   t   commandt
   output_dirt   varsRd   RY   R
   (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyt   preÃ   s     


	

 (   s   pylonss   templates/default_project(   R   R?   t   _template_dirt   staticmethodR   t   template_renderert   summaryt   egg_pluginsR   t   FalseRp   Rm   Rq   (    (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyRV   ¶   s   t   MinimalPylonsTemplatec           B   s,   e  Z d Z d Z e d d d d ƒg Z RS(   R    s   templates/minimal_projects#   Pylons minimal application templateRY   s)   mako/genshi/jinja2/etc: Template languageRZ   R[   (   s   pylonss   templates/minimal_project(   R   R?   Rr   Ru   R   Rp   (    (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyRx   à   s   t   PylonsInstallerc           B   s   e  Z e Z d  Z d „  Z RS(   s   config/deployment.ini_tmplc         C   sé   g  } |  i  i d ƒ D]; } | i ƒ  o( | i ƒ  i d ƒ o | | i ƒ  q q ~ } | p t i d IJt i d IJn xM | D]E } t i | |  i ƒ o) |  i	 t i
 | |  i ƒ | d |  i ƒSq‡ Wt t |  ƒ i | | ƒ S(   s‹   
        Called by ``self.write_config``, this returns the text content
        for the config file, given the provided variables.
        s   top_level.txtt   #s&   No modules are listed in top_level.txts<   Try running python setup.py egg_info to regenerate that filet   filename(   t   distt   get_metadata_linest   stripRC   t   syst   stderrt   pkg_resourcest   resource_existst   config_fileRt   t   resource_stringt   superRy   t   config_content(   RJ   Rn   Rp   R=   t   linet   modulest   module(    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyR†   í   s    >
 (   R   R?   Rw   t   use_cheetahRƒ   R†   (    (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyRy   é   s   ((   R   t   loggingR   R   R   t   paste.deploy.convertersR    t   paste.script.appinstallR   t   paste.script.templatesR   R   t   tempitaR   R    t   pylons.configurationt   pylons.i18nt   __all__t	   getLoggerR   RS   R   R   t   i18nR   R   R   R   t   TrueR'   Rw   R	   R   RP   R   R   R   RV   Rx   Ry   (    (    (    sd   /afs/athena.mit.edu/user/x/a/xavid/lib/python2.6/site-packages/Pylons-0.9.7-py2.6.egg/pylons/util.pyt   <module>   s:   			"	*	