ެJc@sdZddkZddkZddkZddklZddkZddklZddkl Z ddk l Z ddk l ZddklZlZdd klZdd klZdd klZdd klZdd klZlZddkZddklZddkl Z ddk!l"Z"l#Z#l$Z$ddk%l&Z&ddk'l(Z(ddk)l*Z*ddk+l,Z-ei.e/Z0de1fdYZ2defdYZ3e3eZ de"fdYZ4dZ5dS(s&Configuration Helpers for TurboGears 2iN(tcopy(t DictMixin(tugettext(t Translator(tconfig(tSessionMiddlewaretCacheMiddleware(tCascade(tRegistryManager(tStaticURLParser(tasbool(t report_libstStatusCodeRedirect(tTGApp(t ErrorHandler(tBunchtget_partial_dicttDottedFileNameFinder(tMapper(tRoutesMiddleware(tRequest(tmake_middlewaretConfigurationErrorcBseZdZdZRS(s1Exception raised for errors in the configuration.cCs ||_dS(N(tmessage(tselfR((s4/usr/lib/python2.6/site-packages/tg/configuration.pyt__init__$s(t__name__t __module__t__doc__R(((s4/usr/lib/python2.6/site-packages/tg/configuration.pyR!stPylonsConfigWrappercBsMeZdZdZdZdZdZdZdZdZ RS(sWrapper for the Pylons configuration. Simple wrapper for the Pylons config object that provides attribute style access to the Pylons config dictionary. When used in TG, items with keys like "pylons.response_options" will be available via config.pylons.response_options as well as config['pylons.response_options']. This class works by proxying all attribute and dictionary access to the underlying Pylons config object, which is an application local proxy that allows for multiple Pylons/TG2 applicatoins to live in the same process simultaneously, but to always get the right config data for the application that's requesting them. Sites, with seeking to maximize needs may prefer to use the Pylons config stacked object proxy directly, using just dictionary style access, particularly whenever config is checked on a per-request basis. cCs||idy |Wqltj o }tid||fqlXq tid|q Wx@|iD]5}t|oti|qztid|qzWdS(Ns#Error registering %s at startup: %ss!Unable to register %s for startups"Unable to register %s for shutdown(R@tcallablet ExceptiontlogtdebugRAtatexittregister(Rtcmdterror((s4/usr/lib/python2.6/site-packages/tg/configuration.pytsetup_startup_and_shutdowns      c Cstiitii|ii}td|dtii|ddtii|ddtii|dg}|i|i ||_ dS(Ntroott controllerst static_filestpublict templates( tostpathtdirnametabspathtpackaget__file__RtjointupdateR0(RRLR0((s4/usr/lib/python2.6/site-packages/tg/configuration.pyt setup_pathss$ cCs6ti||d|iid|iti|dS(sWInitialize the config object. tg.config is a proxy for pylons.config that allows attribute style access, so it's automatically setup when we create the pylons config. Besides basic initialization, this method copies all the values in base_config into the ``pylons.config`` and ``tg.config`` objects. RUR0N(t pylons_configtinit_appRURR0RRX(Rt global_conftapp_conf((s4/usr/lib/python2.6/site-packages/tg/configuration.pyt init_configs   cCsHtdtdddtd}|idddd d |td s    c Csddkl}l}l}ddkl}|d|g}|idD]}|||qG~d|itd_ t td<||i _ d S( s1Setup a renderer and loader for Jinja2 templates.i(t ChoiceLoadert EnvironmenttFileSystemLoader(t render_jinjaRRPRspylons.app_globalsspylons.strict_cN( tjinja2RRRR~RR0R5Rt jinja2_envR4R1tjinja(RRRRRt_[1]RR((s4/usr/lib/python2.6/site-packages/tg/configuration.pytsetup_jinja_rendererYs 1 cCsvtdid|ii}d|ii}d}h|d6dd6}tdi|ti|i|hdS( sSetup template defaults in the buffed plugin. This is only used when use_legacy_renderer is set to True and it will not get deprecated in the next major TurboGears release. sbuffet.template_enginess %s.templatescSs|iidttdS(Ni(RRRR(R((s4/usr/lib/python2.6/site-packages/tg/configuration.pyRtssgenshi.loader_callbacktxhtmlsgenshi.default_formatsbuffet.template_optionsN(RtpopRURRXtadd_template_engineR8(Rttemplate_locationRtoptions((s4/usr/lib/python2.6/site-packages/tg/configuration.pytsetup_default_rendererhs   cCsWhdd6}|itidhx*|iD]\}}ti||q3WdS(Nsapplication/jsons.jsontmimetype_lookup(RXRRt iteritemst mimetypestadd_type(RtlookupR"R$((s4/usr/lib/python2.6/site-packages/tg/configuration.pytsetup_mimetypess   cCsCddkl}|td}|td_|iii|dS(s!Setup SQLAlchemy database engine.i(tengine_from_configs sqlalchemy.spylons.app_globalsN(t sqlalchemyRRZRt sa_engineRUtmodelt init_model(RRtengine((s4/usr/lib/python2.6/site-packages/tg/configuration.pytsetup_sqlalchemys csfd}|S(s#Return a load_environment function. The returned load_environment function can be called to configure the TurboGears runtime environment for this particular application. You can do this dynamically with multiple nested TG applications if necessary. cs$t|}t|}iii||iiiidjoindi joi ndi joi ndi joi ndi joi nioinioindS(s7Configure the Pylons environment via ``pylons.config``.RR/RRRN(RRKRYR^RfRmRR7Rpt renderersRRRRR<Rtuse_sqlalchemyR(R\R](R(s4/usr/lib/python2.6/site-packages/tg/configuration.pytload_environments,         ((RR((Rs4/usr/lib/python2.6/site-packages/tg/configuration.pytmake_load_environments #cCsZt||td}ttdot||i}nt||idg}|S(s3Add middleware which handles errors and exceptions.spylons.errorwareRFi(RRR R RB(RR\tapp((s4/usr/lib/python2.6/site-packages/tg/configuration.pytadd_error_middlewares cCsddkl}ddkl}|d|ijotid|id] section of the Paste ini file (where defaults to main). RRRiN(R RR>RR7RR;RR?RRthasattrRRRtmaybe_make_body_seekableR R6RBtappendRRR9R(R\twrap_appt full_stackR]RR(RR(s4/usr/lib/python2.6/site-packages/tg/configuration.pyt make_base_app=s4         N(R6R4(RRR((RRs4/usr/lib/python2.6/site-packages/tg/configuration.pytsetup_tg_wsgi_app1s K(RRRRRKRYR^RfRmRpRRRRRRRRRRRRRRRRR(((s4/usr/lib/python2.6/site-packages/tg/configuration.pyR.is2 '     =      0 #    csfd}|S(Ncs>tido!tidt|in||S(Ntmake_body_seekablesMaking request body seekable(RZRRERFRR(RR(R(s4/usr/lib/python2.6/site-packages/tg/configuration.pytwrappers ((RR((Rs4/usr/lib/python2.6/site-packages/tg/configuration.pyRs(6RRGRQRRRtUserDictRt pylons.i18nRtgenshi.filtersRtpylonsRRZtbeaker.middlewareRRt paste.cascadeRtpaste.registryRtpaste.urlparserR tpaste.deploy.convertersR tpylons.middlewareR R RR ttg.errorRttg.utilRRRtroutesRtroutes.middlewareRtwebobRttw.apiRRRRRERDRRR.R(((s4/usr/lib/python2.6/site-packages/tg/configuration.pyts>     ? #