; fCc@s_dZdklZlZlZdkZdklZdkl Z l Z de fdYZ de fdYZ d e fd YZd e fd YZd efdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefd YZd!efd"YZd#efd$YZd%efd&YZd'efd(YZd)efd*YZd+efd,YZd-fd.YZ d/e efd0YZ!d1e efd2YZ"d3e"fd4YZ#dS(5s$Revision: 1.8 $(sListTypes TupleTypes StringTypeN(sTag(smkDictslogs FormExceptioncBstZRS(N(s__name__s __module__(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys FormException"ss FieldMissingcBstZddZRS(Ns is mandatorycCs&||_||_ti||dS(N(sfieldsselfsmessages Exceptions__init__(sselfsfieldsmessage((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys__init__$s  (s__name__s __module__s__init__(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys FieldMissing#ssValidationErrorcBstZdZRS(NcCs&||_||_ti||dS(N(sfieldsselfsmessages Exceptions__init__(sselfsfieldsmessage((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys__init__*s  (s__name__s __module__s__init__(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysValidationError)ssValidationFailurecBstZdZRS(NcCs||_ti|tdS(N(serrorssselfs Exceptions__init__smessage(sselfserrors((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys__init__0s (s__name__s __module__s__init__(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysValidationFailure/ssFormPartcBs/tZdZdZdZdZdZdZRS(Ns formStatesstartserrorsconfirmssubmitcCs&|ii|iti}|SdS(N(shandlersscratchsgetsselfs FORMsTATEkEYsFormPartsSTARTsstate(sselfshandlersstate((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysgetStateDs(s__name__s __module__s FORMsTATEkEYsSTARTsINeRRORs INcONFIRMsINsUBMITsgetState(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysFormPart;s sFormcBstZdZdZdZdZdZddZdZd Z d Z d Z dd Z d Z dZdZdZdZRS(NcCsti|dS(N(sTagsinitsself(sself((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysinitJscCs||j o|o t|doy#|i|i|ii|(shiddenshtmlsitemssksv(sselfshiddenskshtmlsv((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys renderHiddens  cCshSdS(N((sselfshandler((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys getHiddenscCsN|iid}| o,|ii}|it |}n|SdS(Nsaction( sselfsattrssgetsactionshandlersreqsgetUrlsurlsclearsstr(sselfshandlersactionsurl((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys getActions  cCs|i|}|o|id|}n |i}|i|}|ii d|d<|i |||i <|i |}d|||fSdS(Nsactions
%s %s
(sselfs getActionshandlersactions buildAttrss formattrss getHiddenshiddensreqsgetInputsgetStates FORMsTATEkEYs renderHiddensfields(sselfshandlersfieldssactionshiddens formattrs((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys renderForms cCs|i||SdS(N(sselfs renderFormshandlerscdata(sselfshandlerscdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys renderConfirmscCs|iiddSdS(Nssubmit.xssubmit(shandlersreqs hasInputs(sselfshandler((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysonSubmitscCs|iiddSdS(Ns confirm.xsconfirm(shandlersreqs hasInputs(sselfshandler((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys onConfirmedscCs|iiddSdS(NsGOTO NEXT PAGE(shandlersreqslog(sselfshandlerscdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysgoNextscCs#|ii|iidS(N(shandlersreqslogs getInputs(sselfshandlerscdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pyssubmitscCs(|i|||i||dSdS(Nsform submitted(sselfssubmitshandlerscdatasgoNext(sselfshandlerscdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysdoSubmits(s__name__s __module__sinits validatorsvalidates preProcesss prepareDatas__call__s renderHiddens getHiddens getActions renderForms renderConfirmsonSubmits onConfirmedsgoNextssubmitsdoSubmit(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysFormIs           sFieldcBstZdZdZdZddZdZdZdZd Z d Z dd Z d Z d Z dZdZdZRS(NicCs|idSdS(Nsname(sselfsgetAttrs(sself((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysgetNamescCs~|iidd}t|do|io"|i||i||}n|i ||}| o|Sn|SdS(Nsvaluessrecord( sselfsgetAttrssgets startvalueshasattrsrecordsfromDbsnameshandlers getFormValuesvalue(sselfshandlersnamesvalues startvalue((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys getStartValues"scCs|ii||SdS(N(shandlersreqsgetInputsnamesdefault(sselfshandlersnamesdefault((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys getFormValuescCs#|o|i||Sn|SdS(N(srecordsgetsnames defaultValue(sselfsnamesrecords defaultValue((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysfromDbscCsU|i}|i|tijo|i||}n|i ||}|SdS(N( sselfsgetNamesnamesgetStateshandlersFormsSTARTs getStartValuesvalues getFormValue(sselfshandlersvaluesname((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysgetValues  cCsd|i}|i||}|ip|iido| ot |in|SdS(Nsrequired( sselfsgetNamesnames getFormValueshandlersvaluesREQUIREDsgetAttrssgets FieldMissing(sselfshandlersnamesvalue((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysisGivens  (cCs|i|SdS(N(sselfsisGivenshandler(sselfshandler((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysvalidatescCs|SdS(N(scdata(sselfshandlerscdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pyscDatascCs|iido2|i|}|i|||i||Sn|i |t i jo2|i|}|i |||i||Sn|i |t i jon|ii|d}t|to#|i|||i||Sq|i |||i||Sn|i |t ijo;|ii|d}|i|||i||Sn|i|}|i |||i||SdS(Nsreadonlys(sselfsgetAttrssgetsgetValueshandlersvaluesrenderReadOnlyscDatascdatasgetStatesFormsSTARTsrenderEditablesINeRRORsscratchs isinstances FormExceptions renderInErrors INcONFIRM(sselfshandlerscdatasvalue((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys__call__s #####cKsti||SdS(N(sTags buildAttrssselfskws(sselfshandlerskws((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys buildAttrsscCs3d|i||i|||i|fSdS(Ns&%s <- %s: %s (sselfsrenderEditableshandlersgetValuescdatasgetNamesvalue(sselfshandlersvaluescdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys renderInError scCsm|o;d|id|i|d|||idfSn(d|id|i|d|fSdS(Ns<%s %s>%sstagnamesvalues <%s %s />(scdatasselfsgetAttrss buildAttrsshandlersvalue(sselfshandlersvaluescdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderEditables;cCs$d||i|i|fSdS(Ns3%s(svaluesselfsgetNamesgetValueshandler(sselfshandlersvaluescdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderReadOnlyscCsd}|i}t|tgjo6t|d|ft||}di |Snd||i|i |fSdS(Ns-%scCs||||fS(N(shsvsn(snsvsh((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysss,s3%s( shtmlsselfsgetNamesnamestypesvaluessmapslensfieldssjoinsgetValueshandler(sselfshandlersvaluesscdatasnamesfieldsshtml((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderReadOnlys  %(s__name__s __module__sREQUIREDsgetNames getStartValues getFormValuesfromDbsgetValuesisGivensvalidatescDatas__call__s buildAttrss renderInErrorsrenderEditablesrenderReadOnly(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysFields           s DefaultFieldcBs#tZeZeZdZdZRS(NscCsti||io|iid|in|iid o[|i o9|ii t |i  }|di |d|_n|i|id(sselfsgetNamesgetValueshandler(sselfshandlersvaluescdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderReadOnlyCs(s__name__s __module__sTYPEsEXTsrenderReadOnly(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysHidden@ssMultiplecBs)tZdZdZddZdZRS(NscheckedsvaluescCs|ii|SdS(N(shandlersreqs getInputssname(sselfshandlersnamesdefault((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys getFormValueMscKs|i|}|i|}t|tgjo |g}n|ii d}|o@||jot ||i cCs||||fS(N(shsvsn(snsvsh((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys}ss,( shtmlsselfsgetNamesnamestypesvaluessmapslensfieldssjoin(sselfshandlersvaluesscdatasnamesfieldsshtml((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderReadOnlyys  %(s__name__s __module__s getFormValuesrenderEditablesrenderReadOnly(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysOptionsqs  sSubmitcBs&tZdZdZdZdZRS(NsSubmitssubmitcKsH|i|tijod|d%s(sselfsgetLabelsvaluesgetNamesgetValueshandler(sselfshandlersvaluescdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderReadOnlysc Cs|i}d}x|D]}t|ttfjoPt|}|djo|\}}}q|d|ddf\}}}n||df\}}}t |t |jo d}nd||||f}qW|SdS(Nsiiisselecteds#%s(sselfsOPTIONSsoptionss optionListsostypesListTypes TupleTypeslensolensvalueslabelschosensstrsselected( sselfsselectedsvalueschosenslabelsos optionListsolensoptions((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys getOptionLists   $ cCs|iid}|tjo |iSn|i|i}t|i d|}t |ddjott||}n|SdS(NsoptionscCs |i|S(N(sxssplitsch(sxsch((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pyssii( sselfsgetAttrssgetsoptionssNonesOPTIONSssplits FIRSTSplitsmaps SECONDSplitslen(sselfsoptions((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys getOptionss  ( s__name__s __module__sEXTsOPTIONSs FIRSTSplits SECONDSplitsinitsrenderEditablesgetLabelsrenderReadOnlys getOptionLists getOptions(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysSelects    sTextAreacBstZdZdZRS(NsTextAreacCs7|i|}|o |}nti|||SdS(N(sselfsgetValueshandlersvaluescdatas DefaultFieldscData(sselfshandlerscdatasvalue((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pyscDatas (s__name__s __module__sEXTscData(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysTextAreassFilecBs\tZdZdZdZdZdZdZdZdd Z d Z d Z d Z RS( NsFilesfiles
current choice: %s ssavedAsssaveds%(filename)scCsFti||||i}ti||||i}||fSdS(N( s DefaultFields getStartValuesselfshandlersnamesSAVEDsfilenamesSAVEDASstempname(sselfshandlersnamesfilenamestempname((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys getStartValuesscCsa|ii|}|tjpt|tdjo|Sn|i|i |i fSdS(Ns( shandlersreqsgetFilesnamesfilesNonestypesdefaultskeepsfilenamestempname(sselfshandlersnamesdefaultsfile((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys getFormValues & cCsd}d}|tjpt|tdj o;|\}}|iid|i |i ||}nt i |||||SdS(Nss currentlabel(sfilenamescurrentsfilesNonestypestempnamesselfsgetAttrssgets CURRENTLABELsreadOnlys DefaultFieldsrenderEditableshandlerscdata(sselfshandlersfilescdatasfilenamescurrentstempname((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderEditables ' /cCsW|tjpt|tdj o|\}}n d}d}|i||SdS(Ns(sfilesNonestypesfilenamestempnamesselfsreadOnly(sselfshandlersfilescdatasfilenamestempname((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderReadOnlys 'c CsJ|i}td||id||id|d|}|i |SdS(NssavedssavedAssfilenamestempname( sselfsgetNamesnamesmkDictsSAVEDsSAVEDASsfilenamestempnamesattrss READoNLYhTML(sselfsfilenamestempnamesnamesattrs((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysreadOnlys /( s__name__s __module__sEXTsTYPEs CURRENTLABELsSAVEDASsSAVEDs READoNLYhTMLs getStartValues getFormValuesrenderEditablesrenderReadOnlysreadOnly(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysFiles  sPasswordEncodercBstZdZdZRS(NcCs.|d djod|i|Sn|SdS(Nisx:(sxsselfscrypt(sselfsx((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysencodescCsti|}|iSdS(N(smd5snewsxseggs hexdigest(sselfsxsegg((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pyscrypt s(s__name__s __module__sencodescrypt(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysPasswordEncoders s PasswordGroupcBstZdZRS(NcCs'|i|}d|i|fSdS(Ns*(sselfsencodesvaluesgetName(sselfshandlersvaluescdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderReadOnlys(s__name__s __module__srenderReadOnly(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys PasswordGroup ss PasswordInputcBs,tZdZdZdZdZdZRS(NspasswordiicCsd|i|fSdS(Ns.****(sselfsgetNamesvalue(sselfshandlersvaluescdata((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysrenderReadOnlyscCszti||}t|iidt|i }t ||jot |i d|n|i|SdS(Nssizes must be %d characters or longer(sInputsvalidatesselfshandlersvaluesintsgetAttrssgetsstrsSIZEssizeslensValidationErrorsgetNamesencode(sselfshandlersvaluessize((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysvalidates '(s__name__s __module__sTYPEsSIZEsREQUIREDsrenderReadOnlysvalidate(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys PasswordInputs  sPasswordConfirmInputcBstZdZdZRS(NcCsti|d||SdS(Nspassword(s PasswordInputsfromDbsselfsrecordsvalue(sselfsnamesrecordsvalue((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysfromDb$scCsg|iti||}|i|iid}||jot |i dn|SdS(Nspasswords8must be the same as what you entered for password( sselfsencodesInputsvalidateshandlersvaluesreqsgetInputspasswdsValidationErrorsgetName(sselfshandlerspasswdsvalue((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysvalidate's  (s__name__s __module__sfromDbsvalidate(((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pysPasswordConfirmInput#s ($s __version__stypessListTypes TupleTypes StringTypesmd5sparsersTagsutilsmkDictslogs Exceptions FormExceptions FieldMissingsValidationErrorsValidationFailuresFormPartsFormsFields DefaultFieldsInputsGroupsReadOnlysHiddensMultiplesCheckBoxsRadiosOptionssSubmitsSelectsTextAreasFilesPasswordEncoders PasswordGroups PasswordInputsPasswordConfirmInput( sCheckBoxsGroups FieldMissingsSubmitsFields DefaultFieldsInputsHiddens StringTypesMultipleslogsForms PasswordGroupsValidationFailuresmkDicts __version__s PasswordInputsValidationErrorsFormPartsPasswordEncodersListTypes TupleTypesOptionssmd5sTextAreasReadOnlysTagsRadiosFilesPasswordConfirmInputs FormExceptionsSelect((s7/home/groups/p/ps/pso/htdocs/tutorial/Lists/pso/form.pys?s8   x`   ; /