mò DµMc@sÛdZdkZdkZdddddddgZdefd „ƒYZdefd „ƒYZdefd „ƒYZd „Z d „Z defd„ƒYZ defd„ƒYZ e djodkZeiƒndS(s5 This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html) Provides: - List; like list but returns None instead of IndexOutOfBounds - Storage; like dictionary allowing also for `obj.foo` for `obj['foo']` NtListtStoragetSettingstMessagest StorageListt load_storaget save_storagecBstZdZed„ZRS(so Like a regular python list but a[i] if i is out of bounds return None instead of IndexOutOfBounds cCs8d|jot|ƒjno ||Sn|SdS(Ni(titlentselftdefault(R RR ((t7/home/camdpams_www/Products_Activation/gluon/storage.pyt__call__s$ (t__name__t __module__t__doc__tNoneR (((R Rs cBs_tZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z RS( s: A Storage object is like a dictionary except `obj.foo` can be used in addition to `obj['foo']`. >>> o = Storage(a=1) >>> print o.a 1 >>> o['a'] 1 >>> o.a = 2 >>> print o['a'] 2 >>> del o.a >>> print o.a None cCs!||jo ||SndSdS(N(tkeyR R(R R((R t __getattr__9s  cCs7|djo||jo ||=q3n |||(tdictt__repr__R (R ((R RLscCs t|ƒS(N(RR (R ((R t __getstate__OscCs+x$|iƒD]\}}|||>> request = Storage() >>> request.vars = Storage() >>> request.vars.x = 'abc' >>> request.vars.y = ['abc', 'def'] >>> request.vars.getlist('x') ['abc'] >>> request.vars.getlist('y') ['abc', 'def'] >>> request.vars.getlist('z') [] N(R tgetRRRt isinstancetlistttuple(R RR((R tgetlistVs cCs,|i|ƒ}t|ƒo |dSndS(s*Return the first or only value when given a request.vars-style key. If the value is a list, its first item will be returned; otherwise, the value will be returned as-is. Example output for a query string of ?x=abc&y=abc&y=def >>> request = Storage() >>> request.vars = Storage() >>> request.vars.x = 'abc' >>> request.vars.y = ['abc', 'def'] >>> request.vars.getfirst('x') 'abc' >>> request.vars.getfirst('y') 'abc' >>> request.vars.getfirst('z') iN(R R#RRRR(R RR((R tgetfirstqs   cCs,|i|ƒ}t|ƒo |dSndS(s0Returns the last or only single value when given a request.vars-style key. If the value is a list, the last item will be returned; otherwise, the value will be returned as-is. Simulated output with a query string of ?x=abc&y=abc&y=def >>> request = Storage() >>> request.vars = Storage() >>> request.vars.x = 'abc' >>> request.vars.y = ['abc', 'def'] >>> request.vars.getlast('x') 'abc' >>> request.vars.getlast('y') 'def' >>> request.vars.getlast('z') iÿÿÿÿN(R R#RRRR(R RR((R tgetlastˆs   ( R RRRRRRRRR#R$R%(((R R"s         cBstZdZd„ZRS(sI like Storage but missing elements default to [] instead of None cCs/||jo ||Sng||<||SdS(N(RR (R R((R R£s   (R RRR(((R RŸs cCsRt|dƒ}ti|tiƒti|ƒ}ti |ƒ|i ƒt |ƒS(Ntrb( topentfilenametfpt portalockertlocktLOCK_EXtcPickletloadtstoragetunlocktcloseR(R(R)R/((R Rªs   cCsSt|dƒ}ti|tiƒtit|ƒ|ƒti |ƒ|i ƒdS(Ntwb( R'R(R)R*R+R,R-tdumpRR/R0R1(R/R(R)((R R³s  cBstZd„ZRS(NcCs}|djo1|iddƒo||jotd|‚n|djo$|iddƒotd|‚n|||