mò CµMc@sdZdkZdkZdkZdklZlZdklZdk l Z l Z dk l Z dk lZdklZdklZlZlZlZlZd klZlZd klZdkZd klZdkZdk Z d k!l"Z"l#Z#dk$Z$dk%Z%dk&Z&e&i'd ƒZ(dk)Z)y dk*Z*Wne(i+dƒnXei,i-Z.dZ/de0fd„ƒYZ1e2dd„Z3d„Z4d„Z5d„Z6d„Z7d„Z8d„Z9d„Z:d„Z;d„Z<d„Z=d„Z>d„Z?e@d jodkAZAeAiBƒndS(!s This file is part of the web2py Web Framework Copyrighted by Massimo Di Pierro License: LGPLv3 (http://www.gnu.org/licenses/lgpl.html) Functions required to execute app components ============================================ FOR INTERNAL USE ONLY N(sStoragesList(sparse_template(s restrictedscompile2(slistdir(s regex_expose(s translator(s BaseAdaptersSQLDBsSQLFieldsDALsField(sSQLFORMsSQLTABLE(sCache(sgetcfs(sHTTPsredirecttweb2pysunable to import py_compiles$ def _TEST(): import doctest, sys, cStringIO, types, cgi, gluon.fileutils if not gluon.fileutils.check_credentials(request): raise HTTP(401, web2py_error='invalid credentials') stdout = sys.stdout html = '

Testing controller "%s.py" ... done.


\n' \ % request.controller for key in sorted([key for key in globals() if not key in __symbols__+['_TEST']]): eval_key = eval(key) if type(eval_key) == types.FunctionType: number_doctests = sum([len(ds.examples) for ds in doctest.DocTestFinder().find(eval_key)]) if number_doctests>0: sys.stdout = cStringIO.StringIO() name = '%s/controllers/%s.py in %s.__doc__' \ % (request.folder, request.controller, key) doctest.run_docstring_examples(eval_key, globals(), False, name=name) report = sys.stdout.getvalue().strip() if report: pf = 'failed' else: pf = 'passed' html += '

Function %s [%s]

\n' \ % (pf, key, pf) if report: html += CODE(report, language='web2py', \ link='/examples/global/vars/').xml() html += '
\n' else: html += \ '

Function %s [no doctests]


\n' \ % (key) response._vars = html sys.stdout = stdout _TEST() t LoadFactoryc Bs;tZdZd„Zedgheeeeed„ ZRS(s8 Attention: this helper is new and experimental cCs ||_dS(N(t environmenttself(RR((t:/home/camdpams_www/Products_Activation/gluon/compileapp.pyt__init__Xstindexc  Csdk} |pdttiƒƒd}|id}d|jo|iddƒ\}}n| p|o}| p.t i |i||d|d|d|d |ƒ} t id | |fd d ƒ} t id | t idd|ƒƒSn/|p|i}ti|iƒ} | iƒ} |i| _|| _|| _|p|i | _ t|ƒ| _|i| _|i| _|p(|i| _|i | _ |i!| _!n || _| | d<| i"ƒ}|| d<| |_$|ii%| i_&|| i_'d||| i f|_(t)||| ƒ}t+|t,ƒoK||_-x|D]}|||i$|R?R9RR5((Rt__call__Zs` !   '                #(t__name__t __module__t__doc__RR=tFalseRA(((RRTs  twelcomecCst|iddƒ}d||f}t|ƒ}x*|idƒdD]}t||ƒ}qBW|ot |ƒn|S(s In apps, instead of importing a local module (in applications/app/modules) with:: import a.b.c as d you should do:: d = local_import('a.b.c') or (to force a reload): d = local_import('a.b.c', reload=True) This prevents conflict between applications and un-necessary execs. It can be used to import any module, including regular Python modules. t/R sapplications.%s.modules.%siN( tnametreplacetitemstappt __import__tmoduleRtitemtgetattrtforcetreload(RHRPRKRJRMRN((Rtlocal_import_aux•s cCsjh}x$tiD]}tt|ƒ||íst local_importt databasesN(!RRt__all__R9ROt_gURLRt validatorsR)tStoraget translatorRTRURRVtCacheRXRYRZR[R\R]RRERt BaseAdaptert set_foldertostpathtjoinR(R"R/(RRRVRR9((Rtbuild_environmentÍs:              cCsti|ƒdS(s/ Bytecode compiles the file `filename` N(t py_compiletcompiletfilename(Rp((Rtsave_pycôscCsbt|dƒ}|iƒ}|iƒt o$|d tiƒjo t d‚nt i |dƒS(sz Read the code inside a bytecode compiled file if the MAGIC number is compatible :returns: a code object trbiscompiled code is incompatibleiN( topenRptfptreadtdatatclosetis_gaetimpt get_magict SystemErrortmarshaltloads(RpRtRv((Rtread_pycûs   cCs¹tii|dƒ}xt|dƒD]Œ}t||ƒ}d|iddƒiddƒ}tii|d|ƒ}t |dƒ}|i |ƒ|i ƒt|ƒti|ƒq%Wd S( sI Compiles all the views in the application specified by `folder` tviewss ^[\w/]+\.\w+$s views/%s.pyRGt_s\tcompiledtwN(RjRkRlR(tlistdirtfiletparse_templateRvRIRpRsRttwriteRwRqtunlink(R(RtRvRpR„Rk((Rt compile_views s"   cCsÌtii|dƒ}x°t|dƒD]Ÿ}ttii||ƒdƒ}|iƒ}|i ƒtii|dd|i ddƒƒ}t|dƒ}|i |ƒ|i ƒt|ƒti|ƒq%Wd S( sJ Compiles all the models in the application specified by `folder` tmodelss.+\.py$R Rsmodels/RGR€R‚N(RjRkRlR(RƒR„RsRtRuRvRwRIRpR†RqR‡(R(RtRvR„RkRp((Rtcompile_modelss  (   c Cs tii|dƒ}xît|dƒD]Ý}ttii||ƒdƒ}|iƒ}|i ƒt i |ƒ}x‘|D]‰}|d|}tii|dd|d idd ƒd |d ƒ}t|d ƒ}|i|ƒ|i ƒt|ƒti|ƒquWq%Wd S( sO Compiles all the controllers in the application specified by `folder` t controllerss.+\.py$R s% response._vars=response._caller(%s) Rs controllers/iýÿÿÿRGR€s.pyR‚N(RjRkRlR(RƒR„RsRtRuRvRwt regex_exposetfindalltexposedR&tcommandRIRpR†RqR‡( R(RtR&RŽRvRR„RkRp((Rtcompile_controllers.s"  8   csó|di}tii|dƒ}tii|ƒo:x·t|ddƒD]‰tt ˆƒ|dˆƒqHWnttii|dƒddƒ}x\|D]T‰ˆ‰t ot ˆˆ‡‡d†ƒ}nt ˆˆd ƒ}t||ˆƒq—Wd S( s„ Runs all models (in the app specified by the current folder) It tries pre-compiled models first before compiling them. RRs^models_.+\.pyc$itlayerR‰s ^\w+\.py$csttˆdƒiƒˆƒS(NR (tcompile2RstmodelRuR‘((R“R‘(RR_YsN(RR(RjRkRltexistsRƒR“t restrictedR~R‰R‘RxtgetcfstcodeR=(RR—R‰R‘RkR(R“((R‘R“Rt run_models_inGs" !  cs|di} tii| dƒ} d||f}d||f} tii | ƒoutii| d||fƒ} tii | ƒp&t dt i ii| d| ƒ‚ntt| ƒ|d| ƒnÃ|d jo¨tii| d |ƒ} tii | ƒp&t dt i ii|d|ƒ‚n|iƒ|d >> import traceback, types >>> environment={'x':1} >>> open('a.py', 'w').write('print 1/x') >>> save_pyc('a.py') >>> os.unlink('a.py') >>> if type(read_pyc('a.pyc'))==types.CodeType: print 'code' code >>> exec read_pyc('a.pyc') in environment 1 N((((Rttestös t__main__(CRDRjR"RtstorageReR'ttemplateR…R•R’t fileutilsRƒtmyregexRŒt languagesRftsqlRhRZR[RXRYtsqlhtmlR\R]RWRgtsettingstcfsR–RRdthttpRTRUR|Rytloggingt getLoggertloggerR¡Rntwarningtglobal_settingstweb2py_runtime_gaeRxR¦tobjectRRERRRmRqR~RˆRŠRR˜R4R:R´R¶R·RBtdoctestttestmod(0R4RTRRxR¡R¦RgReRZRYRdRqR:R’RURhRXR•RmRyRR–RŠR[R\RÅRƒRR~R]R'RŒRˆR·RRR"R´RfRÃRÀR˜RRÊRnR…RjR|R¶((Rt? s\       %           'A6 '       A :