m (Ec@s_dZdkZdkZdkZdklZlZdkl Z dk l Z dk l Z dklZdklZlZdklZlZd klZd klZd klZd klZeZeid dedeZ eidddddZ"dfdYZ#de eee e fdYZ$ee$ei%edS(s ReStructuredText Product for Zope This Product stores two texts - a "source" text in ReStructureText format, and a HTML "formatted" version of that text. N(sHTMLTranslatorsWriter(sImplicit(s Persistent(sItem(sPropertyManager(s Historicals html_diff(sInitializeClasssDTMLFile(sClassSecurityInfo(sModuleSecurityInfo(sDateTime(sgetConfigurationsView management screenstmanage_addZReSTFormsdtml/manage_addZReSTFormsAdd RestructuredText Documenttmanage_addZReSTtcCsQ|i|t||i|i||dj o|i ||SndS(sAdd a ZReST product N( tselft _setObjecttidtZReSTt_getObt manage_uploadtfiletREQUESTtNonet manage_main(RRR R ((t3/data/zmath/zope/lib/python/Products/ZReST/ZReST.pyR!s  tWarningscBstZdZdZRS(NcCs g|_dS(N(Rtmessages(R((R t__init__*scCs|ii|dS(N(RRtappendtmessage(RR((R twrite,s(t__name__t __module__RR(((R R)s RcBstZdZdZeZeZZeedZ hdd<dd<dd<d d Z d?Z!e!Z"d@Z#d dAZ$dBZ%RS(MskAn instance of this class provides an interface between Zope and ReStructuredText for one text. sReStructuredText DocumentcCsd||_||_d|_d|_d|_dkl}l}|p||_ |p||_ dS(NRt2(sdefault_output_encodingsdefault_input_encoding( RRttitlet stylesheett report_leveltsourcetreStructuredTexttdefault_output_encodingtdefault_input_encodingtinput_encodingtoutput_encoding(RRRRRR((R R7s     RRttypetstringtmodetwtdefaultRRRRs iso-8859-15RitlabeltEdittactionR tViewt index_htmltSourcet source_txtcCs5|dj o|iidd|in|iS(s$ Getting the formatted text s content-typestext/html; charset=%sN(R R tRESPONSEt setHeaderRRtrender(RR ((R R)[s cCs2|dj o|iidd|in|iS(s! Getting the source text s content-typestext/plain; charset=%sN(R R R,R-RRR(RR ((R R+cs sEdit ReStructuredTextsdtml/manage_editFormt manage_edittChanget50t20cCs|ii|o|i|||||Sn||i jo||_ |i n|dj o d}|i ||d|SndS(s,Alias index_html to roundup's index sSaved changes.tmanage_tabs_messageN(Rt _size_changesthas_keytSUBMITt_ertdatat dtpref_colst dtpref_rowsR Rt _clear_cacheR RR (RR8R6R9R:R R((R R/ps  tBiggeritSmalleritNarrowertWidertTallertShorterc Cs7|i|\} } ttdt|| }t|} | i do4tt dtdt| d | d} n ttdt| | } tddi}|d i}|d |d d d ||d| d d d ||iihd| <d |<|i||d|i|S(Nit%idiii#tGMTimR,R:tpatht/texpiresR9t__str__(RR4R6tdrtdctstrtmaxtintR:trowsR9tcolstendswithtmintDateTimetrfc822teR t setCookietothertupdateR t quotedHTMLR8( RR8R6R9R:R RTRMRSRHRIRN((R R7s 4 "RWt&s&ts>t"s"cCsj|djo|i}nxF|D]>\}}|i|djo|i|i |}q$q$W|S(Ni( ttextR Rtread_rawtcharacter_entitiestretnametfindtjointsplit(RR\R^R`R_((R RWs   R;cCsDy |`Wntj onXy |`Wntj onXdS(s& Forget results of rendering. N(Rt _v_formattedtAttributeErrort _v_warnings(R((R R;s  RcCsmt|tdo ||_n|i|_|i|dj o d}|i ||d|SndS(s6 Replaces the current source with the upload. RsSaved changes.R3N( t isinstanceR R RRtreadR;R R RR (RR R R((R Rs   R.cCs|idjohdd<d|i<d|i<d|i<dd<d|i<d d<d t<d d <d d <}t i i |i dt d||_n|iS(s# Render the source to HTML t halt_leveliRRRtinitial_header_leveliRtstylesheet_pathspub.settings.warning_streamtfile_insertion_enabledit raw_enabledtwritertsettings_overridesN(RRdR RRRRRtsettingstdocutilstcoretpublish_stringRtWriter(RRp((R R.so  tPUTt manage_FTPputcCs|idd}||ijo|ido|i}g}xtt |D]y}||}|idpPn|ido|i dd|_ qW|ido|i dd|_qWqWWdi|di||}n||_n|id |S( s" Handle HTTP PUT requests tBODYRs.. s.. stylesheet=t=is.. report_level=s iN(R tgetR8RRt startswitht splitlinestnewtrangetlentitlineRcRRRbR,t setStatus(RR R,RR|RR8((R Rus(  $  cCs|iiidddd|id|ig}|io4|id|iddi |ii n|iddi |d|i S( s% Get source for FTP download s Content-Types text/plainsW.. This is a ReStructuredText Document. Initial comment lines (".. ") will be stripped.s.. stylesheet=s.. report_level=s.. s .. s N( RR R,R-RRtsRfRRbR{R(RR((R t manage_FTPgets  ' cCs|i|iS(s' Stringfy .. return the source N(RRWR(R((R RGscCs|iS(sG Support for searching - the document's contents are searched. N(RR(R((R tPrincipiaSearchSource sc Cs1tid||||dt|i|iS(Ntmanage_historyComparethistoryComparisonResults(RtinheritedAttributeRtrev1trev2R t html_diffR(RRRR R((R RscCs ti||}|i|S(sA re-render the page after changing the properties (encodings!!!) N(tPropertyManagertmanage_editPropertiesRR tresultR;(RR R((R Rs (ii(ii(ii(ii(ii(ii(RXs&(RYs<(RZs>(R[s"(&RRt__doc__t meta_typetClassSecurityInfotsecurityR RdRfRt _propertiestproperty_extensible_schema__Rtmanage_optionst HistoricaltItemtdeclareProtectedR)R+tDTMLFiletglobalsR R/R4R7tdeclarePrivateRWR;RR.RuRvRRGt__call__RRR(((R R/sF   Z   <           (&Rtsyst docutils.coreRqt docutils.iotdocutils.writers.html4css1tHTMLTranslatorRtt AcquisitiontImplicitt Persistencet PersistenttOFS.SimpleItemRtOFS.PropertyManagerRt OFS.HistoryRRtGlobalstInitializeClassRt AccessControlRtModuleSecurityInfotDateTime.DateTimeRQt App.configtgetConfigurationtmodulesecurityRRRR RRRtapply(RtRQRRRRRRqRRRRRRRRRRRRR((R t? s.           "