Ñò ªè·Jc@sddkZddklZddklZlZddklZlZdgZ de fd„ƒYZ de fd„ƒYZ dS( iÿÿÿÿN(t EngineManager(tRequestLocalDescriptortdisable_runtime_checks(tStackedObjectProxytRegistryt HostFrameworkt RequestLocalcBseZd„ZRS(cCs||_h|_dS(N(tenviront resources(tselfR((s0/usr/lib/python2.6/site-packages/tw/mods/base.pyt__init__ s (t__name__t __module__R (((s0/usr/lib/python2.6/site-packages/tw/mods/base.pyR scBs˜eZdZeddƒZeZeddƒZddd„e ddd„Z d„Z d„Z d „Zd „Zd „Zd „Zd „Zd„ZRS(sJ This class is the interface between ToscaWidgets and the framework or web application that's using them. The an instance of this class should be passed as second argument to :class:`tw.core.middleware.ToscaWidgetsMiddleware` which will call its :meth:`start_request` method at the beginning of every request and :meth:`end_request` when the request is over so I have a chance to register our per-request context. A request-local proxy to a configured instance is placed at the beginning of the request at :attr:`tw.framework` **Constructor's arguments:** engines An instance of :class:`tw.core.view.EngineManager`. default_view The name of the template engine used by default in the container app's templates. It's used to determine what conversion is neccesary when displaying root widgets on a template. translator Function used to translate strings. enable_runtime_checks Enables runtime checks for possible programming errors regarding modifying widget attributes once a widget has been initialized. Disabling this option can significantly reduce Widget initializatio time. .. note:: This operation modifies the Widget class and will affect any application using ToscaWidgets in the same process. aggregation_config This option can either be None, or must be a dictionary. The dictionary can have two keys, **js** and **css**. The value of each key is a list of dicts with the following keys: - **modname** the module to create the resource link from. - **filename** the filename relative to the **modname** of the aggregated resources. - **map** the mapping-file for the aggregated resources. If not given, defaults to ``.map``. tnames ToscaWidgets per-request storaget default_viewt toscawidgetscCs|S(((ts((s0/usr/lib/python2.6/site-packages/tw/mods/base.pytFscCs’|djo tƒ}n||_||_||_|djo ||_n||_|p tƒn||_h|_h|_ d|_ dS(N( tNoneRtenginest _default_viewt_default_enginet translatorRtaggregation_configtaggregated_js_mappingtaggregated_css_mappingt middleware(R RRRtenable_runtime_checkstdefault_engineR((s0/usr/lib/python2.6/site-packages/tw/mods/base.pyR Es            cCs9|d}|i|i|i|ƒƒ|i|i_dS(s° Called by the middleware when a request has just begun so I have a chance to register the request context Widgets will use for various things. spaste.registryN(tregistert request_localtrequest_local_classRR(R Rtregistry((s0/usr/lib/python2.6/site-packages/tw/mods/base.pyt start_request[s cCsdS(sf Called by the middleware when a request has just finished so I can clean up. N((R R((s0/usr/lib/python2.6/site-packages/tw/mods/base.pyt end_requestescCsW|iid}|iid}t|dƒo|id}ndi|||gƒS(s> Returns the absolute path for the given url. stoscawidgets.prefixt SCRIPT_NAMEt url_mappingtnormalt(RRthasattrR$tjoin(R turltprefixt script_name((s0/usr/lib/python2.6/site-packages/tw/mods/base.pyR)ls cCs'ddkl}||ii|ƒdS(sK Registers resources for injection in the current request. iÿÿÿÿ(tmerge_resourcesN(ttw.apiR,RR(R RR,((s0/usr/lib/python2.6/site-packages/tw/mods/base.pytregister_resourcesvscCsš|ii}h|i_|owd|joj|idj o|iƒn|io|i||itƒn|io|i||it ƒq–n|S(s” Returns returns the resources that have been registered for this request and removes them from request-local storage area. theadN( RRRRt_setup_aggregation_mappingRt"_replace_resources_with_aggregatestJSLinkRtCSSLink(R R((s0/usr/lib/python2.6/site-packages/tw/mods/base.pyt pop_resources}s       cCs¼ddkl}l}l}l}|tƒd<|tƒd<|idj oc|i}d|jo|i|d|i |ƒnd|jo|i|d|i |ƒq¯nd|_dS(Niÿÿÿÿ(R2R3tAggregatedJSLinktAggregatedCSSLinkR2R3tjstcss( ttw.core.resourcesR2R3R5R6tglobalsRRt_compute_mappingRR(R R2R3R5R6tconfig((s0/usr/lib/python2.6/site-packages/tw/mods/base.pyR0™s"     "c Cs:tƒ}x*|D]"}|d}|d}d|jo|d}n d|}||f|jotd||fƒ‚n|i||fƒ|d|d|ƒ} x‹ti||ƒD]w} | iƒ} | pq·nt| iddƒƒ} | |jo(|| | j otd| fƒ‚n| || tmap_nametresourcetlinet jslink_desc((s0/usr/lib/python2.6/site-packages/tw/mods/base.pyR;¨s*      c CsÁtƒ}g}x¡|dD]•}t||ƒp|i|ƒqn|i|iƒf}||jo<||}||joqn|i|ƒ|i|ƒq|i|ƒqW||ds