[Zapp-cvs-commit] ZApp ZApp_CMFBase.py,1.40,1.41
Brought to you by:
sspickle
|
From: Steve S. <ssp...@us...> - 2004-03-29 03:41:12
|
Update of /cvsroot/zapp/ZApp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13255 Modified Files: ZApp_CMFBase.py Log Message: fixed problem in DAV/FTP support for ZApp_CMF_Images... Index: ZApp_CMFBase.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_CMFBase.py,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** ZApp_CMFBase.py 28 Mar 2004 22:14:47 -0000 1.40 --- ZApp_CMFBase.py 29 Mar 2004 03:29:49 -0000 1.41 *************** *** 58,62 **** zapp_cmf_type = 1 isPrincipiaFolderish = 1 ! __implements__ = ( ZApp_DublinCoreMixin.__implements__, --- 58,63 ---- zapp_cmf_type = 1 isPrincipiaFolderish = 1 ! isAnObjectManager = 1 ! __implements__ = ( ZApp_DublinCoreMixin.__implements__, *************** *** 363,366 **** --- 364,369 ---- meta_type = 'ZApp CMF FSObject' isPrincipiaFolderish = 0 + isAnObjectManager = 0 + __dav_collection__ = 0 _custom_skin_scripts = ("WITH SELF COMPUTE portal_object_id=_.getattr(self, 'zapp_portal_id')", *************** *** 375,378 **** --- 378,386 ---- + def objectValues(self, spec=None): + return () + + objectIds=objectItems=objectValues + def getFSRoot(self, app=None): """ *************** *** 429,433 **** if self.fs_object is None: ! self.fs_container.manage_addImage(id=newID, title=title, file=file) fileObj = getattr(self.fs_container, newID, None) else: --- 437,441 ---- if self.fs_object is None: ! self.fs_container.manage_addFile(id=newID, title=title, file=file) fileObj = getattr(self.fs_container, newID, None) else: *************** *** 450,454 **** """ fsObj = self.fs_object ! return fsObj and fsObj.index_html(REQUEST=REQUEST, RESPONSE=RESPONSE) def PUT(self, REQUEST, RESPONSE): --- 458,462 ---- """ fsObj = self.fs_object ! return fsObj and fsObj.index_html(REQUEST, RESPONSE) def PUT(self, REQUEST, RESPONSE): *************** *** 457,461 **** newID = self.getId() if self.fs_object is None: ! self.fs_container.manage_addImage(id=newID, title=self.Title(), file=None) if newID in self.fs_container.objectIds(): fileObj = getattr(self.fs_container, newID, None) --- 465,469 ---- newID = self.getId() if self.fs_object is None: ! self.fs_container.manage_addFile(id=newID, title=self.Title(), file=None) if newID in self.fs_container.objectIds(): fileObj = getattr(self.fs_container, newID, None) *************** *** 467,477 **** fileObj.PUT( REQUEST, RESPONSE) ! def manage_FTPget(self, REQUEST=None, RESPONSE=None): ! """ ! Implement ftp get.... ! """ ! fileObj = self.fs_object ! if fileObj: ! return fileObj.manage_FTPget(REQUEST=REQUEST, RESPONSE=RESPONSE) def zcmf_copyToCurrPath( self, oldSelf ): --- 475,479 ---- fileObj.PUT( REQUEST, RESPONSE) ! manage_FTPget = index_html def zcmf_copyToCurrPath( self, oldSelf ): *************** *** 520,523 **** --- 522,554 ---- os.system("mv %s %s" % (oldMetaPath, newMetaPath)) + def get_size(self): + """Get the size of a file or image. + + Returns the size of the file or image. + """ + size = 0 + if self.fs_object: + size = self.fs_object.get_size() + + return size + + # deprecated; use get_size! + getSize=get_size + + def getContentType(self): + """Get the content type of a file or image. + + Returns the content type (MIME type) of a file or image. + """ + return self.content_type + + def __str__(self): + if self.fs_object: + return str(self.fs_object.data) + else: + return '' + + def __len__(self): return 1 + extendProperties(ZApp_CMF_FSObject, []) *************** *** 528,531 **** --- 559,609 ---- _custom_skin_scripts = ( "WITH SELF COMPUTE graphic_url=self.fs_object_url",) + def edit_fs_object(self, id='', title='', file=None, REQUEST=None): + """ + edit the FS object + """ + + if not file: + file = REQUEST and REQUEST.form.get('file',None) + + oldID = self.getId() + newID, newTitle = self.zapp_cook_id( id, title, file ) + + if self.fs_object is None: + self.fs_container.manage_addImage(id=newID, title=title, file=file) + else: + if newID != oldID: + self.fs_container.manage_renameObjects((oldID,), (newID,)) + + fileObj = getattr(self.fs_container, newID, None) + + # + # this allows folks to edit the id/title of an image without requiring a fresh upload.. + # + + if file: + fileObj.manage_upload(file) + self.content_type = fileObj.content_type + self.width = fileObj.width + self.height = fileObj.height + + + return oldID, newID, newTitle + + def PUT(self, REQUEST, RESPONSE): + """Handle HTTP PUT requests""" + + newID = self.getId() + if self.fs_object is None: + self.fs_container.manage_addImage(id=newID, title=self.Title(), file=None) + if newID in self.fs_container.objectIds(): + fileObj = getattr(self.fs_container, newID, None) + else: + fileObj = None + else: + fileObj = self.fs_object + + fileObj.PUT( REQUEST, RESPONSE) + extendProperties(ZApp_CMF_FSImage, []) *************** *** 537,540 **** --- 615,621 ---- zapp_cmf_type = 1 isPrincipiaFolderish = 0 + isAnObjectManager = 0 + __dav_collection__ = 0 + __implements__ = ( |