Ńņ Tć·Jc @sddkZddkZddkZddkZddkZddkZddklZlZddddddgZ d „Z d „Z dddd „Z dddd „Zd efd„ƒYZeƒZd„ZeidƒZd„Zdefd„ƒYZdd&d„ƒYZdefd„ƒYZdefd„ƒYZed„Zdefd„ƒYZdefd„ƒYZd„Z defd„ƒYZ!defd „ƒYZ"dd!d"„Z#defd#„ƒYZ$d$„Z%e&d%joddk'Z'e'i(ƒndS('i’’’’N(tcounttizipt OrderedSettRequestLocalDescriptort lazystringtasbooltLRUCachetdisable_runtime_checkscCsjt|ttfƒoJ|iƒiƒ}|djotS|djotStd |ƒ‚nt|ƒS(Nttruetyestontyttt1tfalsetnotofftntft0sString is not true/false: %r(RR R R R R (RRRRRR( t isinstancetstrtunicodetstriptlowertTruetFalset ValueErrortbool(tobj((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRs  cs‡‡‡fd†}|S(s= Raises 'exc' if given flag is not equal to 'state'. cs:‡‡‡‡fd†}ˆi|_ˆiiƒ|_|S(Ncs1t|ˆƒˆjoˆ|||ŽSˆ‚dS(N(tgetattr(tselftargstkw(tnametstatetfunctexc(s0/usr/lib/python2.6/site-packages/tw/core/util.pytwrapper(s(t func_namet__dict__tcopy(R$R&(R#R%R"(R$s0/usr/lib/python2.6/site-packages/tw/core/util.pytentangle's ((R"R#R%R*((R#R"R%s0/usr/lib/python2.6/site-packages/tw/core/util.pytassert_bool_attr#scs‡‡‡fd†}|S(sķ Decorates a method excecuting pre and post methods around it. Can be used to decorate the same method in different subclasses and takes care that pre is executed only once at the first cooperative call and post once at the end of the cooperative call-chain. >>> entries = 0 >>> exits = 0 >>> def pre(*args, **kw): global entries; entries += 1 >>> def post(*args, **kw): global exits; exits += 1 >>> class A(object): ... @pre_post_wrapper(pre, post) ... def say_name(self, name): ... print name >>> class B(A): ... @pre_post_wrapper(pre, post) ... def say_name(self, name): ... super(B, self).say_name(name) ... print name >>> class C(B): ... @pre_post_wrapper(pre, post) ... def say_name(self, name): ... super(C, self).say_name(name) ... print name >>> c = C() >>> c.say_name('foo') foo foo foo >>> entries 1 >>> exits 1 A reentrant lock can be passed to syncronize the wrapped method. It is a must if the instance is shared among several threads. cs:‡‡‡‡fd†}ˆi|_ˆiiƒ|_|S(Ncs’dˆi}ˆoˆiƒnzĄt||dƒd}t|||ƒ|djoˆoˆ|||Žnˆ|||Ž}t||ƒ}t|||dƒ|djo,t||ƒˆoˆ|||ŽqįnWdˆoˆiƒnX|S(Ns__%s_wrapper_counterii(R'taquireRtsetattrtdelattrtrelease(RR R!t counter_nametcountertoutput(tpretlockR$tpost(s0/usr/lib/python2.6/site-packages/tw/core/util.pyR&\s$   (R'R(R)(R$R&(R3R4R5(R$s0/usr/lib/python2.6/site-packages/tw/core/util.pyR*[s ((R3R5R4R*((R3R4R5s0/usr/lib/python2.6/site-packages/tw/core/util.pytpre_post_wrapper4s'cs‡‡‡fd†}|S(Ncs:‡‡‡‡fd†}ˆi|_ˆiiƒ|_|S(Nc s{dˆi}tti|iƒƒ}ˆoˆiƒnz$t||dƒd}t|||ƒ|djoMˆoFxC|D]7}y|iˆ|||ŽWq~t j oq~Xq~Wnˆ|||Ž}t||ƒ}t|||dƒ|djo^t ||ƒˆoFxC|D]7}y|iˆ|||ŽWqt j oqXqWq]nWdˆoˆi ƒnX|S(Ns__%s_wrapper_counterii( R'tlisttinspecttgetmrot __class__R,RR-R(tKeyErrorR.R/(RR R!R0tbasesR1tbaseR2(R4t post_nameR$tpre_name(s0/usr/lib/python2.6/site-packages/tw/core/util.pyR&vs:    (R'R(R)(R$R&(R4R?R>(R$s0/usr/lib/python2.6/site-packages/tw/core/util.pyR*us ((R?R>R4R*((R4R?R>s0/usr/lib/python2.6/site-packages/tw/core/util.pytpre_post_hooksts"t CachedInspectcBs2eZdZd„Zd„Zd„Zd„ZRS(s¢ In general "inspect" calls are extremely expensive. However, if we cache them on an object by object basis, we should be able to speed things up a cCs1tiƒ|_tiƒ|_tiƒ|_dS(N(tweakreftWeakKeyDictionaryt functionstmethodstargspec(R((s0/usr/lib/python2.6/site-packages/tw/core/util.pyt__init__žscCsD|ii|dƒ}|djoti|ƒ}|i|eZdZeded„Zdd„Zd„Zd„Z RS(s×A descriptor that proxies to tw.framework.request_local for passing state among widgets in a thread-safe manner for the current request. Do not abuse this or code can become increasingly unmantainable! cCs3||_||_||_|pd||_dS(sįProxy to request local storage attribute named by ``name``. If ``default`` is provided no AttributeError will be raised if attribute does not exist ar request local storage when getting or deleting. If ``qualify_with_id`` is True, the name is extended with the id() of the widget. **Not** with the widget.id though! This prevents the collapsing of namespaces for several forms on one page being rendered after validation. s'%s' at request-local storageN(R"tdefaulttqualify_with_idRS(RR"R{RSR|((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRGs   cCsŚ|djo|Sddk}|ii}|i}|io|dt|ƒ7}nyt||ƒSWnmtj oa|i t jo‚qÖy|i ƒ}Wnt j o|i }nXt |||ƒ|SnXdS(Ni’’’’s_%i( RIttwt frameworkt request_localR"R|RlRtAttributeErrorR{Ryt TypeErrorR-(RRttypR}RR"tvalue((s0/usr/lib/python2.6/site-packages/tw/core/util.pyt__get__s$     cCsWddk}|ii}|i}|io|dt|ƒ7}nt|||ƒdS(Ni’’’’s_%i(R}R~RR"R|RlR-(RRRƒR}RR"((s0/usr/lib/python2.6/site-packages/tw/core/util.pyt__set__/s     cCs…ddk}|ii}|i}|io|dt|ƒ7}nyt||ƒWn*tj o|it jo‚qnXdS(Ni’’’’s_%i( R}R~RR"R|RlR.R€R{Ry(RRR}RR"((s0/usr/lib/python2.6/site-packages/tw/core/util.pyt __delete__8s    N( RQRRRSRyRIRRGR„R…R†(((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRs   cCsØddk}t|dƒ p|o€ddkl}l}ddkl}|iƒ}|ƒ}|iƒ|i hdd6dd6|d 6ƒ||d d ƒ|_ ndS( Ni’’’’R~(tStackedObjectProxytRegistry(R=tt SCRIPT_NAMEs /toscawidgetsstoscawidgets.prefixspaste.registryR"tToscaWidgetsFramework( R}thasattrttw.core.registryR‡Rˆttw.modsR=t HostFrameworktpreparet start_requestR~(tforceR}R‡RˆR=tdummy_frameworktdummy_registry((s0/usr/lib/python2.6/site-packages/tw/core/util.pytinstall_frameworkFs      tEnumcBs eZdZd„Zd„ZRS(s,Less strict Enum than the one provided by TGcGsx|D]}|||>> string = "aaaabbbcc" >>> replacer = MultipleReplacer({ ... 'a+':lambda g, context: g + context['after_a'], ... 'b+':lambda g, context: g + context['after_b'], ... 'c+':lambda g, context: context['before_c'] + g, ... }) >>> replacer("aaaabbbcc", dict( ... after_a = "1", ... after_b = "2", ... before_c = "3" ... )) 'aaaa1bbb23cc' icCsMdid„|iƒDƒƒ|_|iƒ|_ti|i|ƒ|_dS(Nt|cssx|]}d|VqWdS(s(%s)N((t.0Ri((s0/usr/lib/python2.6/site-packages/tw/core/util.pys ²s (tjointkeyst _raw_regexptvaluest _substitutorstretcompilet_regexp(Rtdcttoptions((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRG±s"cCs d|iit|ƒ|ifS(Ns<%s at %d (%r)>(R:RQRlRÆ(R((s0/usr/lib/python2.6/site-packages/tw/core/util.pyt__repr__¶scs‡‡‡fd†}|S(NcsKxDtˆi|iƒƒD]*\}}|dj o||ˆˆŽSqWdS(N(RR±RcRI(Rbt substitutortgroup(R R!R(s0/usr/lib/python2.6/site-packages/tw/core/util.pyRø»s  ((RR R!Rø((RR R!s0/usr/lib/python2.6/site-packages/tw/core/util.pyt _subsitutorŗscOs|ii|i||Ž|ƒS(N(R“tsubRŗ(RR R R!((s0/usr/lib/python2.6/site-packages/tw/core/util.pyt__call__Įs(RQRRRSRGR·RŗR¼(((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRŖ–s    iccs-ti|||ƒx|D] }|VqWdS(s‡Make an iterator that run warnings.warn(message, category, stacklevel) right before the first value from iterator is returned. N(twarningstwarn(Rwtmessagetcategoryt stackleveltx((s0/usr/lib/python2.6/site-packages/tw/core/util.pytiwarnÅscBs]eZdZdefd„ƒYZdd„Zd„Zd„Zd„Zd„Z d „Z RS( s$A dictionary-like object that stores a limited number of items, discarding lesser used items periodically. this is a rewrite of LRUCache from Myghty to use a periodic timestamp-based paradigm so that synchronization is not really needed. the size management is inexact. t_ItemcBseZd„Zd„ZRS(cCs%||_||_tiƒ|_dS(N(RoRƒttimet timestamp(RRoRƒ((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRGŲs  cCs t|iƒS(N(treprRƒ(R((s0/usr/lib/python2.6/site-packages/tw/core/util.pyR·Üs(RQRRRGR·(((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRÄ×s gą?cCs||_||_dS(N(tcapacityt threshold(RRČRÉ((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRGßs cCs(ti||ƒ}tiƒ|_|iS(N(R›t __getitem__RÅRĘRƒ(RRoRv((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRŹćscCs+g}ti|ƒD]}||iq~S(N(R›R°Rƒ(Rt_[1]ti((s0/usr/lib/python2.6/site-packages/tw/core/util.pyR°čscCs(||jo ||S|||<|SdS(N((RRoRƒ((s0/usr/lib/python2.6/site-packages/tw/core/util.pyR^ės   cCs_ti||ƒ}|djo)|i||ƒ}ti|||ƒn ||_|iƒdS(N(R›RHRIRÄRœRƒt _manage_size(RRoRƒRv((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRœņs   cCsŒx…t|ƒ|i|i|ijo`ti|ƒ}|id„ƒx:||iD]+}y||i=WqTtj oPqTXqTWqWdS(NcSst|i|iƒS((R§RĘ(tatb((s0/usr/lib/python2.6/site-packages/tw/core/util.pytžs(RVRČRÉR›R°tsortRoR;(RtbytimeRv((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRĶūs$( RQRRRStobjectRÄRGRŹR°R^RœRĶ(((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRĪs     cCs ddkl}|`|`dS(sW Disables runtime checks for possible programming errors regarding modifying widget attributes once a widget has been initialized. This option can significantly reduce Widget initialization time. NOTE: This operation modifies the Widget class and will affect any application using ToscaWidgets in the same process. i’’’’(tWidgetN(ttw.apiRŌRRš(RŌ((s0/usr/lib/python2.6/site-packages/tw/core/util.pyRst__main__(()R8R²tsysR½RÅRBt itertoolsRRt__all__RR+RIR6R@RÓRARURYR³RaRuR7RRyRzRRR•R›R–R™RŸRRŖRĆRRRQtdoctestttestmod(((s0/usr/lib/python2.6/site-packages/tw/core/util.pytsJ        @%   + E   / 9