Annotation of ExtFile/ExtFile.pyc, revision 1.1

1.1     ! dwinter     1: m
        !             2: Ec  @sdZd&ZdZ&dklZ&dklZ&dklZ&dkl    Z  &dk
        !             3: lZlZl
Z
lZ&dklZlZ&d klZ&d
        !             4: klZ&dklZ&dklZ&d
klZ&dklZ&dkZdkZdkZdkZdk Z dk!Z!dk"l#Z#l$Z$&dk%l&Z&&dk'l(Z(&dk)l*Z*&dk+l+Z+&dZ,dZ-dk.TdZ/y
dk0Z0Wne1j
        !             5: o
&&&&dZ2n&XdZ2ydk3l4Z4&WnGe1j
        !             6: o;&&&&ydk5l4Z4&Wn e1j
        !             7: o&&&&dk6l4Z4&n&Xn&Xydk7l8Z8&Wne1j
        !             8: o
&&&&dZ8n&Xydk9l:Z:&Wne1j
        !             9: o
&&&&e;Z:n&Xei<Z=ei>Z?dZ@dZAdkBZBeBiCd &ZDdkETed!eFZGd"d"d"d"d"dde;d#ZHdeeee   fd$YZIe
eI&&d%ZJd&ZKeiLeJeKZMd'ZNd(kOlPZP&d)kQlRZR&e;d*&ZSdkTZTd+eUf&d,YZVd-fd.YZWe:e;j   o&d/fd0YZXn&&dS(1s ExtFile product module sExtFile product module.
        !            10:     The ExtFile-Product works like the Zope File-product, but stores 
        !            11:     the uploaded file externally in a repository-direcory.s1.5.4(&sCatalogAware(&s
        !            12: SimpleItem(&sPropertyManager(&s   Cacheable(sHTMLFiles
MessageDialogsInitializeClassspackage_home(sClassSecurityInfosgetSecurityManager(&sPermissions(&s
        !            13: aq_acquire(&sguess_extension(&sResourceLockedError(&srfc1123_date(&sDateTimeN(sjoinsisfile(&s
TemporaryFile(&sTM(&sWriteLockInterface(&sIExtFiletExtFilei(&t&*cCst||&&d&S(tloggingN(tinfottxtttxt2(RtmethodR((t//usr/local/testzope/Products/ExtFile/ExtFile.pytLOGOs&&i&(&sguess_content_type(&sRedirecttRedirect(&sIStreamIteratorsChange ExtFile/ExtImagesDownload ExtFile/ExtImages(^(copy[0-9]*_of_)+)sdtml/extFileAddtc 
        !            14: Cs&|&o}&t&|d&d d   j  od&|i}&|&tti|&dti|&dti|&dd}&|p&|&}t  |&&}&n&&t
        !            15: |&||||}   |i|&| &|djo&|i|&&i||&n&&|d j  o&|i||dd&Sn&&|&S(
        !            16: s Add an ExtFile to a folder. tfilenamet&/s&\t&:i&R
        !            17: tupdate_menuiN(tidtgetattrtfiletNoneRtmaxtstringtrfindttitletnormalize_idRtdescrtpermission_checktredirect_default_viewttempExtFiletselft
        !            18: _setObjectt_getObtmanage_file_uploadtcontent_typetREQUESTtmanage_main(
        !            19: RRRRRR RRR!R((Rtmanage_addExtFileps&!  &&&&
&&&&
&&
&&cBstZ&dZeefZhd&d<dd<dd<hd&d<dd<dd<hd&d   <dd<dd<hd&d
        !            20: <dd<dd<hd&d<dd<dd<fZd
Zd
Zhdd<dd<hdd<dd<hdd<dd<fe   i
        !            21: ei
        !            22: dei
        !            23: Z
        !            24: e
ZdZeZeied&ep&eied&n&&hdhdd<<dhdd<dd <dd<d!d"<<d#hd$d%<d&d'<d(d'<d)d*<d+d,<d-d.<dd<<d/hdd<<d0hdd<<dd<Zddd
d
d1Zd2Zd3Zd4Zd5Zeied6&d
d
eeed7Zeied8&d9Zeied:&dd;&Z eied<&d=Z!eied>&d?Z"eied@&dAZ#eiedB&dCZ$eiedD&dEZ%eiedF&dGZ&eiedH&dIZ'eiedJ&dKZ(eiedL&dMZ)eiedN&dOZ*eiedP&d
d
dQZ+eiedR&dSZ,eie-dT&dUZ.eiedV&dWZ/eie-d&e0dXe1Z2eie3dY&ddedZZ4eie-d&e0d[e1Z5eie3d\&dded]Z6eie3d^&dded_Z7eie3d`&eda&Z8eie3db&dcZ9eiddde&eidddf&eidddg&dhZ:edi&Z;edj&Z<dkZ=dlZ>dmZ?dnZ@doZAdpZBdqZCeeddrZDeeddsZEd
d
dtZFd
d
duZGedv&ZHdwZIdxZJeiKdy&&edz&ZLeiKd{&&d|ZMeiKd}&&d~ZNeiKd&&dZOeiKd&&dZPdZQdZRdZSdZTdZUdZVRS(s The ExtFile-Product works like the Zope File-product, but stores 
        !            25:         the uploaded file externally in a repository-direcory. RRttypeRtmodet&wRttextR tuse_download_permission_checktbooleanRitlabeltEdittactionR"tViewR
        !            26: tUploadtmanage_uploadFormi&RtManagert_dummytimagetdefaultsdefault.gifthtmlshtml.giftxmlsxml.giftpythonspy.giftapplicationtpdfspdf.giftzipszip.gifttartmswordsdoc.giftexcelsxls.gift
        !            27: powerpointsppt.giftvideotaudiocCsL|&|_||_||_||_||_t|_g|_d&|_  dS(s& Initialize a new instance of ExtFile R
        !            28: N(
        !            29: RRRRRR(Rt__version__RR (RRRRRR((Rt__init__s&&   &   &   &   &   &   &   &c&&&Cs
        !            30: |i&S(&N(Rt
        !            31: index_html(&R((Rt__str__s&c&&&Csd&S(Ni&((&R((Rt__len__s&cCs
&|&i&d&d}|dj o&ti|dd}ytt|&i&}Wn
&&&d}n&X|dj  o&|io&t|i&}n
&td&}|djo]&||joP&t
|i&}|&iid|&|&iid|i&|&iid&&dSq&&q   &&n&&dS( s HTTP If-Modified-Since header handling: return True if
        !            32:             we can handle this request by returning a 304 response.
        !            33:         sIf-Modified-Sincet&;is
Last-ModifiedsContent-Typei0&i&N(R!t
        !            34: get_headerRtheaderRtsplittlongtDateTimettimeTimet   mod_sinceRt_p_mtimetlast_modtrfc1123_datetRESPONSEt  setHeaderR t  setStatus(RR!RNRLRG((Rt"_if_modified_since_request_handlers$&&
&&&
        !            35: &
&
        !            36: &&&&&cCsh|i&oZ&|ioI&|&oA&|id&|&}||ijo&|i  i
        !            37: |&&dSq`&qd&n&&dS(s redirect_default_view property handling: return True if
        !            38:             we can handle this request by returning a 302 response.
        !            39:             Patch provided by Oliver Bleutgen.
        !            40:         tpreviewi&N(RRtstatic_modeticont_static_urlRTt
        !            41: static_urltabsolute_urlR!RPtredirect(RRVRTR!RX((Rt&_redirect_default_view_request_handlers&
        !            42: &&&&&RBcCs|dj    oG&|i|&o&|id&&d&Sn&&|i|&||o&d&SqT&n&&|i|&|\}
        !            43: }
}&}|i|
        !            44: &}
        !            45: tdjo$&t
ttd|
        !            46: |
|&|f&n&&d}|
        !            47: o;&yti|
        !            48: &d}  WqX&&&&|d|i|
        !            49: fqX&Xn_&ttt&dd}
        !            50: yti|
        !            51: &d}  Wn&&&|d|i|
        !            52: fn&Xd  }
d}&|&d
        !            53: jo&&|dj    o&&|dj    o&t}ydkl}&|i|
        !            54: &}|i djo&|i!d&}n&&|i"}t$|d
o
&|i%}n&&|i&t'|&t'|&f|}|i(|ddd&&Wn&&&t|
        !            55: d}qX|i)d
        !            56: d&|i*} |i)d
        !            57: &&d}
n&t|
        !            58: d}d}z|dj o&t,|i-&}|i/i0d|&|i/i0d|
&|i/i0d| &|id&&t1dj   o&d
        !            59: }t2|&Sn&&dd>}x<|i4|&}|i/i6|&&t7|&|jo&Pq&q&Wd&Sn&|i4SWd|o&|i8&n&&XdS(s3 Return the file with it's corresponding MIME-type R
        !            60: i&sserving %s, %s, %s, %ssCan't read: is%s (%s)ticonss
        !            61: broken.gifs image/gifi(&sImagetRGBt   ANTIALIAStJPEGtqualityiUtrbis
        !            62: image/jpegs
Last-ModifiedsContent-TypesContent-LengthiN(9R!RRRStZCacheable_setR[RVRTt_get_file_to_serveRR t_get_fsnamet_debugRt_SUBSYStINFOt
cant_read_exctoststattsizeRtjointpackage_hometglobalstwidththeightt
TemporaryFiletdatatPILtImagetopentimR%tconverttBICUBICtfilterthasattrR^tresizetinttsavetseekttellt
        !            63: close_dataRORMRNRPRQtIStreamIteratortstream_iteratort    blocksizetreadtbuffertwritetlentclose(RRVRTRoRpR!RRRvRkRRhRR RrRtRyRN((RRB&s
&&
&&&
$&&&&&&&'&    &&
&&&& &&
&$&&&&&
&
        !            64: &&
&&&&&

&&
        !            65: &&&&&
        !            66: &&&tview_image_or_filec&&Cst|id&S(s8 The default view of the contents of the File or Image. N(R RRY(&R((RRO&s&&tlinkcKsz|&d&jo&|i}&n&&d|i}x6|iD](}|i|&}d|||f}q:Wd||&f}|S(s$ Return a HTML link tag to the file R
        !            67: s<a href="%s"s
        !            68: %s %s="%s"s %s>%s</a>N(
        !            69: R'Rttitle_or_idRWtstrgtargstkeystkeytgettvalue(RR'RRRR((RRT&s&&
&&
&&&&ticon_gifc&&Cst|id&d&dS(s) Return an icon for the file's MIME-Type RVi&N(R    RRW(&R((RR_&s&&ticon_tagc&&Csd&|i&dd&S(s( Generate the HTML IMG tag for the icon s<img src="%s" border="0" />RVi&N(RRW(&R((RRd&s&&t icon_htmlc&&&Cs
        !            70: |i&S(s Same as icon_tag N(RR(&R((RRi&s&&t  is_brokenc&&Cs|i&|i&S(s@ Check if external file exists and return true (1) or false (0) N(RRdR(&R((RRn&s&&tget_sizec&Cs2|i&|i&}&|&o&ti|&&d&Sn&&dS(s' Returns the size of the file or image iiN(RRdRtfnRiRj(RR((RRs&s
        !            71: &&&&&trawsizec&&&Cs
        !            72: |i&S(s Same as get_size N(RR(&R((RR{&s&&tgetSizec&&&Cs
        !            73: |i&S(s Same as get_size N(RR(&R((RR&s&&Rkc&&Cs|i&|i&S(s: Returns a formatted stringified version of the file size N(Rt
_bytetostringR(&R((RRk&s&&tgetContentTypec&&&Cs|i&S(s: Returns the content type (MIME type) of a file or image. N(RR (&R((RR&s&&tgetIconPathc&Cs&yti&|id&\}}&WnHtj
        !            74: o<&&&&t|dddj    o&d  \}}&qj&d
        !            75: \}}&n&X|i    i
        !            76: |&or&|i    |d}xJ|i |iD]5}ti|&|djo&|i ||}Pq&qWtd||Sn&&td|i dS(s Depending on the MIME Type of the file/image an icon
        !            77:             can be displayed. This function determines which
        !            78:             image in the lib/python/Products/ExtFile/icons/...
        !            79:             directory shold be used as icon for this file/image
        !            80:         Rthas_previewR2R
        !            81: R3iR\N(simageR
        !            82: (R
        !            83: R
        !            84: (RRHRR tcattsubt
        !            85: ValueErrorRRt_typesthas_keyRRtitemtfindRl(RRRRR((RR&s &&&&&&&&&&& &&RXcCs|i&|&|S(s$ Returns the static url of the file N(RRWRVRT(RRVRT((RRX&s&&RUc&&Csti&id&&dj   S(s% Returns true if serving static urls tEXTFILE_STATIC_PATHN(RitenvironRR(&R((RRU&s&&tget_filenamec&&Cs|i&|i&S(si Returns the filename as file system path. 
        !            86:             Used by the ZMI to display the filename.
        !            87:         N(Rt_fsnameR(&R((RR&s&tPrincipiaSearchSourcec&&Cs%|i&id&&o&t|&Sn&&dS(s, Allow file objects to be searched.
        !            88:         stext/R
        !            89: N(RR t
        !            90: startswithtstr(&R((RR&s&&&sdtml/extFileEdittmanage_editExtFilecCsy|i&|&jo
&|&|_&n&&|i|jo
&||_n&&|i&|i&|dj    o&|i||d&d&Sn&&dS(s Manage the edited values tmanage_tabs_messagesSaved changes.N(RRRtreindex_objecttZCacheable_invalidateR!RR"(RRRR!((RR&s&&
&

        !            91: 
        !            92: 
&sdtml/extFileUploadt
manage_uploadcCsp|i&o
&td&n&&t|&&tijo'&t}|i    |&&&|i
        !            93: d&&n&|&}|i|||S(s/ Upload file from file handle or string buffer sFile is locked via WebDAViN(Rtwl_isLockedtResourceLockedErrorR$Rttypest
        !            94: StringTypeRqt    temp_fileRR~RR R!(RRR R!R((RR&s&&
&
&  &
&&RcCs6&|i&o
&td&n&&t|&&tijo0&d}yt|&d}&Wq`&&&||&q`Xn&&|o&t
        !            95: |&|}&n&&|i|&|&id&|i
|i   |_    |&id&&|i&z/|i|i&}|i|&|i|&&Wd|i&X||_|i&|dj o&|i||dd&Sn&&dS(    s1 Upload file from file handle or local directory sFile is locked via WebDAVsCan't open: RaidiNRsUpload complete.(RRRR$RRRRhRuR t
        !            96: HTTPUploadt_get_content_typeRRR~t    _registert_get_ufnRtnew_fnt_update_datat_temp_fsnamet_dir__unlockt_afterUpdateR!RR"(RRR R!RRh((RR&s0&&
&
&&&&&&&&
&
        !            97: &&&&&&    &
        !            98: &
&tmanage_http_uploadcCs &|i&o
&td&n&&ti|&d}&d}yti|&&}Wn&&&||&n&Xt  |&}|i
        !            99: ||id&|i|i
|_
|id&&|i&z/|i|i&}|i||i|&&Wd|i&X||_|i&|dj    o&|i||dd&Sn&&dS(    s Upload file from http-server sFile is locked via WebDAVs/:sCan't open: idiNRsUpload complete.(RRRturllibtquoteturlRhturlopenRRRRRR R~RRRRRRRRR!RR"(RRR!RRRh((RRs.&&
&
&&&
&&&&
&
        !           100: &&&&&&    &
        !           101: &
&tPUTcCsA&|i&|&|&|i|&|d&d&&|&d}|&idd}|o&t    ||}n&&|i
        !           102: ||id&|i|i|_|i
d&&|i&zry|i&Wn)tj
        !           103: o&&&&|i|&id&}n&Xd}|i|id|&&}|i||i|&&Wd|i&X||_|i&|id    &&|S(
        !           104: s Handle HTTP PUT requests trefreshi&tBODYFILEscontent-typeiditpathNi(Rt  dav__initR!RPtdav__simpleifhandlerRRFRR RRRRR~Rt  aq_parenttAttributeErrort_get_zodb_pathtPARENTSRRRRRRRRRR(RR!RPRR RR((RRs2&&&&
        !           105: &&&&&&
&
        !           106: &&&&&&&&&  &
        !           107: &
&s
        !           108: FTP accesstmanage_FTPstattmanage_FTPlistt
manage_FTPgetc&&Cs|i&d&|i&S(s Return body for FTP R!N(RRBR!(&R((RR:s&&cCs|&djo&&t|d&ddj   o
&|i}&n&&t|ddo2&|&djp&tiit|o&dSn&dSdS(s3 Check if the user is allowed to download the file R!R(ii&N(R!RRRtgetSecurityManagertgetUserthas_permissiontDownloadPermission(RR!((Rt_access_permittedBs&&&&
&=cCst|&d&d}|o&|id&o&|d}nK&t|&td&j    o
&|i}n&&t t|&d|||\}}|id&}|djo&|| Sn&&|S(s Determine the mime-type theadersscontent-typeR
        !           109: RREiN(RRRRRR R$tbodyRrtguess_content_typeRtencRtcutoff(RRRRR RRR((RROs&&&&
&&&&
&&cCst|&&tijo&|i|&&}&n&&t|&tijo&|i|&}n&&y|i|&|&WnB&&&t|&o+&yt i
        !           110: |&&Wqtj
        !           111: o&&&&q&Xn&&nX|i&d&S(s Store infile to outfile N(
R$tinfileRtListTypeRRtoutfilet_copytisfileRitremovetOSErrorthttp__refreshEtag(RRR((RR]s&&&&&&&&&
&&  &c
        !           112: Cs&t|&&tijoI&yt|&d&}Wn)tj
        !           113: o&&&&td|i|&fn&Xd}n
&|&}d}t|&tijo|&tit
&}y*t|d}ti|&&|i&Wn6tj
        !           114: o*&&&&ti|&&td|i|fn&Xd}n
&|}d}yadd>}  |i|    &}|i|&&x4t|&|   jo &|i| &}|i|&&q5&&WWn)tj
        !           115: o&&&&td|itfn&Xy|id&&Wn&&&n&X|o&|i&n&&|o&|i&n&&dS(  s Read binary data from infile and write it to outfile
        !           116:             infile and outfile may be strings, in which case a file with that
        !           117:             name is opened, or filehandles, in which case they are accessed
        !           118:             directly.
        !           119:         Ras%s (%s)i&itwbiiN(R$RRRRutinstreamtIOErrorRRtclose_inRRitumasktREPOSITORY_UMASKt  outstreamRt  close_outRRtblockRRRR~R(
        !           120: RRRRRRRRRR((RRmsN&&&&&&
        !           121: &&&&&&
&&&
&&
        !           122: &&&
        !           123: &&
&&&&&&&&&c&Csc|i&|i&}&t|&&o?&t|&d&&o.&|i&ti|&d&|i|i&&n&&dS(s- Restore filename after delete or copy-paste s.undoN(    RRRRRRRitrenameR(RR((Rt_undos
        !           124: &&&&
        !           125: &cCsktg&}|i|i&&t|&&tijo&|i|&&&n&|&d&jo&|i   |&&&n&&t
        !           126: t|S(sr Generates the full filesystem name, incuding directories from 
        !           127:             self._repository and filename
        !           128:         R
        !           129: N(t
INSTANCE_HOMERtextendRt_repositoryR$RRRtappendtapplyRl(RRR((RRs&    &&&&
&&cCsd&|i&|&&S(s: Generates the full filesystem name of the temporary file s%s.tmpN(RRR(RR((RRs&&cCsk|i&|&&}t|&o&|Sn&&|i|&&}t|&o&|Sn&&|i&t|&o&|Sn&&d&S(s Returns the full filesystem name, preferring tmp over main. 
        !           130:             Also attempts to undo. Returns None if the file is broken.
        !           131:         N(RRRttmp_fnRRRR(RRRR((RRds&&
&&&
&&
        !           132: &
&cCs
|i&|&&S(s Deprecated, use _get_fsname N(RRdR(RR((Rt
_get_filenames&&cCstt&jp
&|&gjo"&|id&|d|d|}n&|&}|&o&|i    |&&}tt&jo2&yti||d&Wqt
j
        !           133: o&&&&q&Xq&yti|d|&Wqt
j
        !           134: o&&&&q&Xn&&|S(sp If no unique filename has been generated, generate one
        !           135:             otherwise, return the existing one.
        !           136:         RR tlocks.undoN(tUNDO_POLICYt
ALWAYS_BACKUPRRt_get_new_ufnRR RRRtold_fnRiRR(RRRR RRR((RRs &&"&&&
&& & &cCsa|i&}to=&ti|&}|dj   o&|t|id&&&}qM&n&&ti  |d}|d&o&|| }||}
n
&|}d}
|p
&|i
}n&&tttfjo&t|&}|dj  o&|d jo
        !           137: &d}n&&|d!jo
        !           138: &d}n&&|d"jo
        !           139: &d
        !           140: }n&&|djo&|
p%&ttjo&||
}n&&|}
qP&&qT&&n&&|&dj   o
        !           141: &|&}n
&|i}g}ttjo
        !           142: &|}n[&&ttttfjo&&ttjof&dit|&|g&&}ti t!i"|&i#&d }|i%d
d}|i%dd}n=&ttjo)&t|&}|i&&di|&}n&|}xt't(&D]Q}t|&t*t(|jo&|i+t*d&&qf&|i+|t* &&|t*}qfWn0&tt,jo"&t-|t.}
        !           143: |
        !           144: ||}n&&t0t1jo+&g}|D]}||i4q~}n&&|i5|&}t7ii8|&pW&d}t7i:t;&} yt7i<|&&t7i:|    &&Wq&&&t7i:| &&||qXn&&t=}ti?|ddjo1&ti%|dd}t@tAiBd&&}n&d}d}ti?|ddjo
&|t=n&&ti?|ddjos&tE|dddj    oA&|iFiGd&o.&tHiIiJ}ti%|d|}q&ti%|dd}n&&ti?|ddjo+&tiL|d}ti%|d|}n&&ti?|ddjp&ti?|ddjo.&ti%|d|}ti%|d|
}n&&|o&|iN|&&n&&|o&&t|ti%|dd|}n&t|ti%|dd}x`tP|&p"&tP|d&p&tP|d&o0&|d&}t|ti%|dd|}q&W|o&ti%|dd|}n&ti%|dd}|i+|&&|S(#s Create a new unique filename i&t&.R
        !           145: s.jpegs.jpes.jpgs.objs.exes.tiffs.tifsapplication/octet-streamiRt&_t&+sCan't create directory: s%tis%cs
        !           146: %m%d%H%M%SsInvalid file format: s%uR!tAUTHENTICATED_USERs%ps%ns%es.%ss.undos.tmpN(s.jpegs.jpe(&s.obj(&s.tiff(QRRtCOPY_OF_PROTECTIONt
        !           147: copy_of_retmatchRRtgroupRRtpostid_nametid_extR tREPOSITORY_EXTENSIONStMIMETYPE_APPENDtMIMETYPE_REPLACEtguess_extensiontmime_extRtrel_url_listRtdirst
        !           148: REPOSITORYt SYNC_ZODBtSLICEDtSLICED_REVERSEtSLICED_HASHRltlistthashedtbase64tencodestringtshatnewtdigestttemptreplacetreversetrangetSLICE_DEPTHt&itSLICE_WIDTHRtCUSTOMt
        !           149: aq_acquiret
CUSTOM_METHODRtNORMALIZE_CASEt   NORMALIZEt_[1]t&dtlowerRtdirpathRitisdirt  mkdir_excRRtmakedirstFILE_FORMATt
        !           150: fileformatRR|RJtstrftimetcountertinvalid_format_excRR!RRRtgetUserNametusert
        !           151: joinfieldsRt
        !           152: _dir__lockRR(RRR RR)&R'&R&R/&RRRR&R&R&R&R&R
        !           153: &RR.&R%&R&R&R,&R$&R    &R1&((RRs&&   &&
&!&&
        !           154: &&&
&&
&
&
        !           155: &
&
        !           156: &
&
        !           157: &
&&
&
        !           158: &
&
        !           159: &&
&"&&&
&&
        !           160: &&
&&&&
&&
&+&&&&&
&&&
&&&&&&
&,&&&2&&&&&/&
        !           161: &'&&
&cCs#&ti&id&&}|d    j  o&|i|&|\}}}&}|&o&d|iSq&&ti&id&}|i
i}|d  j  o-&|d djo&d|}q&d|}n&&|ti|&d}|tidi|&&Sn=&|&o&d|iSn$&|o&d|iSn&|iSd    S(
        !           162: s# Return the static url of the file Rs  %s?icon=1tEXTFILE_STATIC_HOSTishttps://shttp://Rs%s?preview=1N(RiRRtstatic_pathRRRcRVRTRR RYtstatic_hostR!t
        !           163: SERVER_URLthostRRRl(RRVRTR6&RR8&R R5&((RRWVs&&&&
&&&
&&&&&&&cCs|i&p
        !           164: &d&}n&&|o&t|ddo
        !           165: &d&}&n&&|&o(&ttt&|i}d}n0&|o&|i}|i}n&|i   }|i
        !           166: }|||&|fS(s/ Find out about the file we are going to serve i&Ris  image/gifN(
RRRTRRVRlRmRnRRR t
prev_filenametprev_content_type(RRVRTRR ((RRcrs&&
&
        !           167: &&
        !           168: &&
        !           169: &&    &
 &   cCsyd&kl&}&Wntj
        !           170: o&&&&n?&Xt||o-&|id&id&d }td|Sn&&|&djo
&|i}&n&&tt
jo&|&id&id&}n&t|&i&}td|S(s, Returns the ZODB path of the parent object (&s
        !           171: PhotoImagei&RiN(tProducts.Photo.ExtPhotoImaget
        !           172: PhotoImagetImportErrort
        !           173: isinstanceRRYRHRRyRtparentRt   ZODB_PATHtVIRTUALR&tgetPhysicalPath(RR?&R<&R((RRs&&&&&&
&

&&cCst|&&}|d&jo5&|d}|d&jo&|d}d}qT&d}n&d}d|}|d }|dd   jo&|d }n&&||}|S(sq Convert an int-value (file-size in bytes) to an String
        !           174:             with the file-size in Byte, KB or MB
        !           175:         iis MBs KBs Bytess%4.2fiiRN(tfloatRtbytesttypR(RRRRD&RE&((RRs&&
&
        !           176: &
&
        !           177: &
        !           178: 
        !           179: &
        !           180: &
        !           181: &&
        !           182: &c&&Cs2|i&&|i|i|i&|i|iS(sm Called whenever the file data has been updated. 
        !           183:             Invokes the manage_afterUpdate() hook.
        !           184:         N(RRtmanage_afterUpdateRdRR R(&R((RRs&
        !           185: &tmanage_afterClonecCsd&}y|i&Wntj
        !           186: o&&&&d|_n&X|i|i&}|op&|i&z?|p
        !           187: &|i
        !           188: }|i||i|&&||_d}Wd|i
&X|o&|i&q&n&&tid&||&S(s When a copy of the object is created (zope copy-paste-operation),
        !           189:             this function is called by CopySupport.py. A copy of the external 
        !           190:             file is created and self.filename is changed.
        !           191:         ii&NRG&(tcall_afterUpdateRRRt_v_has_been_clonedRdRRRRRRRRRRtinheritedAttributeR(RRRRH&R((RRG&s&&&&&&&&
        !           192: &&&&    &
        !           193: &&&&&tmanage_afterAddcCsQ|i&&t|d&o&t|d&&|i|&&&n&&tid&||&|S(s& This method is called, whenever _setObject in ObjectManager gets 
        !           194:             called. This is the case after a normal add and if the object is a 
        !           195:             result of cut-paste- or rename-operation. In the first case, the
        !           196:             external files doesn't exist yet, otherwise it was renamed to .undo
        !           197:             by manage_beforeDelete before and must be restored by _undo().
        !           198:         RI&RK&N(   RRRztdelattrRG&RRRJ&t container(RRRM&((RRK&s&
        !           199: &&
&&tmanage_beforeDeletecCs|i&|i&}|i|i&}t|&oY&yti||d&&Wnt    j
        !           200: o&&&&q&Xyti
        !           201: |&&Wqt j
        !           202: o&&&&q&Xn@&t|&o2&yti||d&&Wqt    j
        !           203: o&&&&q&Xn&&tid&||&|S(s`& This method is called, when the object is deleted. To support 
        !           204:             undo-functionality and because this happens too, when the object 
        !           205:             is moved (cut-paste) or renamed, the external file is not deleted. 
        !           206:             It is just renamed to filename.undo and remains in the 
        !           207:             repository, until it is deleted manually.
        !           208:         s.undoRN&N(RRRRRRRRiRRRRRJ&RRM&(RRRM&RR((RRN&s$&&&
&&&    &
&&   &RF&c&Csd&S(s This method is called whenever the file data has been updated.
        !           209:             May be overridden by subclasses to perform additional operations.
        !           210:             The 'filename' argument contains the path as returned by get_fsname().
        !           211:         N((RRR Rk((RRF&st
        !           212: get_fsnamec&&Cs|i&|i&S(s& Returns the current file system path of the file or image. 
        !           213:             This path can be used to access the file even while a 
        !           214:             transaction is in progress (aka Zagy's revenge :-). 
        !           215:             Returns None if the file does not exist in the repository. 
        !           216:         N(RRdR(&R((RRO&s&cCs0t|d&o
&tdn&&t|&&|_dS(s Lock a directory t_v_dir__locksDouble lock in threadN(RzRtDirLockErrortDirLocktdirRP&(RRS&((RR3&s&&&
&c&&Cs2t|d&o&|ii&t|d&&n&&dS(s& Unlock a previously locked directory RP&N(RzRRP&treleaseRL&(&R((RRs&&&
&c&&Csato!&t&ttd&ti|&&n&&ti|&&to!&t&ttdti|&&n&&dS(Nsregistering %ss
registered %s(ReRRfRgtTMtcontainsRtregister(&R((RR"s
        !           217: &!&
&c&&Cs/d&|_&to&tttd|i&n&&dS(Ni&sbeginning %s(Rt_v_begin_calledReRRfRgR(&R((Rt_begin's&   &c&Csd&|_&ti|&&|io&|i|i&}&to&tt  t
        !           218: d|&&n&&t|&&ol&to&tt   t
        !           219: d|&&n&&|i|i&}yti|&&Wntj
        !           220: o&&&&n&Xti|&|&q&n&&dS(s Commits the temporary file i&sfinishing %ss isfile %sN(Rt_v_finish_calledRU&RRRRReRRfRgRRRRiRR(RRR((Rt_finish+s && &
&
        !           221: &&&
&&&&&c&Csd&|_&ti|&&|io&|i|i&}&to&tt t
        !           222: d|&&n&&t|&&oJ&to&tt   t
        !           223: d|&&n&&yti|&&&Wqt
j
        !           224: o&&&&q&Xq&n&&dS(s Deletes the temporary file i&saborting %ss  isfile %sN(Rt_v_abort_calledRU&RRRRReRRfRgRRiR(RR((Rt_abort9s&&   &
&
        !           225: &&&
&&&(&sManager(Wt__name__t
        !           226: __module__t__doc__tIExtFiletWriteLockInterfacet__implements__t_propertiesR(RtPropertyManagertmanage_optionst
        !           227: SimpleItemt CacheabletClassSecurityInfotsecurityt    meta_typetREPOSITORY_PATHRtsetPermissionDefaultRtZOPE28tdeclareProtectedRRARCRDRSR[tViewPermissionRRBRRRRRRRRRRkRRRXRUtAccessPermissionRRtHTMLFileRnR"tChangePermissionRR/RRRRRRRRRRRRRdRRRRWRcRRRtdeclarePrivateRG&RK&RN&RF&RO&R3&RRRY&R[&R]&(((RRs&^     &          &L& &
        !           228: & & & & & & & & & & && & & &&
&&
&&& &&& 
      *                   

&
& 

& 
& 
&       
        !           229:          sK ,;:'"()[]{}ݟtK____________AAAAAAaaaaaaCcEEEEEeeeeeIIIIiiiiNnOOOOOOooooooSssUUUUuuuuYYyyZzc&Csyt|d&}WnDtj
        !           230: o8&&}&&yt|d}WqZtj
        !           231: o
&&}&&|SqZ&Xn&X|idd}ti|t}|S(Nsutf-8siso-8859-15tignore(   tunicodeRtuidtUnicodeErrort  TypeErrortencodeRt   translatetTRANSMAP(RRz&Rx&((RRMs&&&&&&&&&(&sFieldStorage(&s
        !           232: FileUploadcCst|to &|&o&|&|id&<n&&|Sn|&hdd<}|&o&|&|d<n9&t|do(&|iid&&o&|id&|d<n&&td|d|}t|&SdS(    sD Create a FileUpload instance from a file handle (and content_type) scontent-typetREQUEST_METHODtPOSTtCONTENT_TYPERtfpRN(
        !           233: R>&R&t
        !           234: FileUploadR RRRzRtFieldStoragetfs(R&R R&R((RR`s&&&&&&&&#&&&RQ&c&BstZ&RS(&N(R^&R_&(((RRQ&ss&RR&c&BsMtZ&dZd&ZdZdZdZdZdZdZ    dZ
        !           235: RS(   s% Manage the lockfile for a directory s@@@lockf1.5i
        !           236: c&Cs-t|id&}&|&id&&|&i&dS(Ntwts3ExtFile dir lock. You may want to remove this file.(RuRt_lockt&fRR(RR&((Rt_mklock}s&&
&c&&Csti&|i&&dS(&N(RiRRR&(&R((Rt_rmlocks&c&&Csti&i|i&&dS(&N(RiRRRR&(&R((Rtislockeds&c&&&Cs|i&&dS(&N(RR&(&R((RRT&s&cCsti&i|&|i|_xt|i&D]I}|i
        !           237: o+&ttt
d&|i&ti|i&&q+&|i&Pq+Wttt
d|i&td|idS(NsWaiting for lock '%s'sFailed to get lock '%s'(RiRRlRS&Rt   lock_nameR&R&tsleep_timesR&R&RRftBLATHERttimetsleept
        !           238: sleep_secsR&RQ&(RRS&R&((RRAs&&&
&&
        !           239: &&(R^&R_&R`&R&R&R&R&R&R&RT&RA(((RRR&vs&&&           RcBs<tZ&ef&Zd&d>d&ZdZdZdZRS(NiicCs|&|_||_dS(&N(tstreamRt_streamRt
        !           240: _blocksize(RR&R((RRAs&   &c&Cs@|i&i|i&}&|&p &|i&i&d|_&t&n&&|&S(&N(RR&RR&RrRRt
StopIteration(RRr((Rtnexts&&&
& &
        !           241: &c&CsH|i&i}&|i&id&d&|i&i}|i&i|&d&&|S(Nii(RR&Rtcur_posR~Rk(RR&Rk((RRDs
        !           242: &&&&&c&&&Cs|i&o&d&p&dS(Ni&i(RRD(&R((Rt__nonzero__s&(R^&R_&RRc&RAR&RDR&(((RRs
        !           243: &      (YR`&R@t&Products.ZCatalog.CatalogPathAwarenesstCatalogAwaretOFS.SimpleItemRg&tOFS.PropertyManagerRe&t  OFS.CacheRh&tGlobalsRr&t
MessageDialogtInitializeClassRmt
AccessControlRi&RtPermissionstAcquisitionR &t mimetypesR&twebdav.LockableRt
webdav.commonRORJRRiRRR&R&tos.pathRlRttempfileRqtProducts.ExtFileRU&twebdav.WriteLockInterfaceRb&Ra&RfReRRtZope2R=&Rn&tzope.contenttypeRtzope.app.content_typestOFS.content_typestzExceptionsR  tZPublisher.IteratorsRRtviewRp&tview_management_screensRq&Rs&RtretcompileRtConfigRntmanage_addExtFileFormR#Rt    bad_charst
        !           244: good_charst maketransR}&RtcgiR&tZPublisher.HTTPRequestR&RR&RRQ&RR&R(:R R&Rh&Rp&RR&R &RJRR&Rb&RRs&RReR#R&RRfRR&RU&RqR&R@Rr&R`&RR&RR&RRRRi&R&Rg&R}&Rq&ROR&RR&RlRR&RR&Rn&R&RQ&Re&Ra&RR&RiR&RmR((Rt&?&s*
&
&
&
&&&
&
&
&
&
&
&6&&
&

&
&  
&&&&&&&   &   &&   &!
        !           245: &&    
&
 $


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>