Ñò ¹_‚Jc@sHdZddkZddkZddklZddklZddkZddkZddkl Z ddk l Z ddk l Z ddklZlZlZdd klZdd klZdd klZdd klZlZdd klZddklZdefd„ƒYZ defd„ƒYZ!de!fd„ƒYZ"de!fd„ƒYZ#de!fd„ƒYZ$de!fd„ƒYZ%defd„ƒYZ&d„Z'd„Z(defd „ƒYZ)d!„Z*d"„Z+d#e,d$„Z-ed%„ƒZ.ed&„ƒZ/ed'„ƒZ0d(efd)„ƒYZ1d*efd+„ƒYZ2dS(,sA Decorators use by the TurboGears controllers. Not all of these decorators are traditional wrappers. They are much simplified from the turbogears 1 decorators, because all they do is register attributes on the functions they wrap, and then the DecoratedController provides the hooks needed to support these decorators. iÿÿÿÿN(t best_match(t decorator(tHTTPUnauthorized(t MultiDict(tPage(tconfigtrequesttresponse(tabort(t tmpl_context(tpartial(tActionProtectortControllerProtector(tBunch(tflasht DecorationcBsneZdZd„Zd„ZeeƒZd„ZeeƒZd„Zd„Z d„Z d„Z d„Z RS( sC Simple class to support 'simple registration' type decorators c Csp||_h|_h|_d|_d|_d|_t|_t|_ t dgdgdgdgƒ|_ dS(Ntbefore_validatet before_callt before_rendert after_render( t controllertenginestcustom_enginestNonetrender_custom_formatt validationt error_handlertFalsetis_default_controllertis_lookup_controllertdictthooks(tselfR((s1/usr/lib/python2.6/site-packages/tg/decorators.pyt__init__$s         cCs*t|dƒp||ƒ|_n|iS(Nt decoration(thasattrR"(tclstfunc((s1/usr/lib/python2.6/site-packages/tg/decorators.pytget_decoration2scCs t|iƒS(N(tboolR(R ((s1/usr/lib/python2.6/site-packages/tg/decorators.pytexposed8scOs)x"|i|D]}|||ŽqWdS(N(R(R thooktltkwR%((s1/usr/lib/python2.6/site-packages/tg/decorators.pyt run_hooks<scCs1|djo d}n|||f|i| for json "/mypage.html" ==> for text/html "/mypage.xml" ==> for xml. If you're doing an http post, you can also declare the desired content type in the accept headers, with standard content type strings. By default expose assumes that the template is for html. All other content_types must be explicitly matched to a template and engine. The last expose uses the custom_format parameter which takes an arbitrary value (in this case 'special_xml'). You can then use the`use_custom_format` function within the method to decide which of the 'custom_format' registered expose decorators to use to render the template. tcCs3|djo g}n|djod \}}nvd|jo|iddƒ\}}nM|o9tidƒotddd}q©tid ƒ}n d\}}|djo!|djo d }q×d }n|djod |jo|id ƒn||_||_||_||_||_ dS(NtjsonRVt:ituse_legacy_renderersbuffet.template_enginesiR.tdefault_renderersapplication/jsons text/htmlR (RWRV(NN( RtsplitRR<RIR.R/R-R0R2(R R/R-R0R2R.((s1/usr/lib/python2.6/site-packages/tg/decorators.pyR!s,             cCskti|ƒ}|io,|i|i|i|i|i|iƒn#|i|i|i|i|iƒ|S(N( RR&R2R3R-R.R/R0R1(R R%RS((s1/usr/lib/python2.6/site-packages/tg/decorators.pyRT)s N(RLRMRNRR!RT(((s1/usr/lib/python2.6/site-packages/tg/decorators.pyRUÇs;  $cCsFti|ƒ}||iiƒjotd|ƒ‚n||_dS(siUse use_custom_format in a controller in order to change the active @expose decorator when available.s!'%s' is not a valid custom_formatN(RR&RRBt ValueErrorR(RR2RS((s1/usr/lib/python2.6/site-packages/tg/decorators.pytuse_custom_format5scCs¹t|dƒo |i}ndSt|dƒo |i}ndS|idƒ}|idƒ}|i|dƒy ti}Wn tj oh}t_nXh|d6||i .pager()} where c is the tmpl_context. It is possible to have several :func:`paginate`-decorators for one controller action to paginate several collections independently from each other. If this is desired, don't forget to set the :attr:`use_prefix`-parameter to :const:`True`. :Parameters: name the collection to be paginated. items_per_page the number of items to be rendered. Defaults to 10 use_prefix if True, the parameters the paginate decorator renders and reacts to are prefixed with "_". This allows for multi-pagination. RVt_tpages%spagetitems_per_pages%sitems_per_pagecs‡‡‡‡fd†}|S(Nc sÛt|iˆddƒƒ}t|iˆdˆƒƒ}tiˆƒdd}|out|ƒ}xft|ƒD]T\}}|t|ƒjoPn||}||jo||||<||=qoqoWnˆ||Ž}t|tƒoíˆ|joàt ƒ}x>t i i ƒD]-\} } | ˆjo|i | | ƒqqW|ˆ} t| |d||iƒ}t|idˆdƒ|_||ˆ sD    €n ""  b