[Zapp-cvs-commit] ZApp ZApp_Application.py,1.33,1.34 ZApp_CMFBase.py,1.39,1.40 ZApp_RelationshipMana
Brought to you by:
sspickle
|
From: Steve S. <ssp...@us...> - 2004-03-28 22:26:08
|
Update of /cvsroot/zapp/ZApp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21319 Modified Files: ZApp_Application.py ZApp_CMFBase.py ZApp_RelationshipManager.py __init__.py Log Message: added FSFolder class Index: ZApp_Application.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_Application.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** ZApp_Application.py 21 Mar 2004 13:08:17 -0000 1.33 --- ZApp_Application.py 28 Mar 2004 22:14:47 -0000 1.34 *************** *** 194,197 **** --- 194,198 ---- {'id':'zapp_app_id','type':'string','mode':''}, {'id':'zapp_portal_id','type':'string','mode':''}, + {'id':'zapp_fSystem_id','type':'string','mode':'w'}, ) *************** *** 203,211 **** manage_leverActionsForm = DTMLFile('manage_ui/leverActionsForm',globals(),management_view='Lever Actions') - manage_leverResults = DTMLFile('manage_ui/leverResults',globals(),management_view='Lever Actions') def __bobo_traverse__(self, REQUEST, name): ! ob = getattr(self, name, _marker) if ob is _marker: --- 204,215 ---- manage_leverActionsForm = DTMLFile('manage_ui/leverActionsForm',globals(),management_view='Lever Actions') manage_leverResults = DTMLFile('manage_ui/leverResults',globals(),management_view='Lever Actions') + zapp_fSystem_id = 'fSystem' # id of localFS object for filesystem based objects... + def __bobo_traverse__(self, REQUEST, name): ! """ ! This is a bit of hackery that allows us to embed namespace values in an url (e.g., portal_skin). ! """ ob = getattr(self, name, _marker) if ob is _marker: *************** *** 397,400 **** --- 401,410 ---- return self + def getFSystemObject(self): + """ + return filesystem object, or None + """ + return getattr(self, self.zapp_fSystem_id, None) + def getException(self): """ *************** *** 508,512 **** continue spec = spec.__of__(leverMethod) ! for rack in spec.rackList: rack = rack.__of__(spec) resultList.append("checking rack: " + `rack`) --- 518,527 ---- continue spec = spec.__of__(leverMethod) ! if leverName=='skinScriptLever': ! rackList = spec.rackList ! else: ! rackList = [spec.defaultRack] ! ! for rack in rackList: rack = rack.__of__(spec) resultList.append("checking rack: " + `rack`) Index: ZApp_CMFBase.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_CMFBase.py,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** ZApp_CMFBase.py 22 Mar 2004 17:24:21 -0000 1.39 --- ZApp_CMFBase.py 28 Mar 2004 22:14:47 -0000 1.40 *************** *** 78,83 **** _insertQueryPrefix = 'self.checkDups() and ' - manage_options = SkinnedFolder.manage_options - displayCustomUpdate_pt = PageTemplateFile('zpt/CMF_displayRelatedObjects', globals()) --- 78,81 ---- *************** *** 264,268 **** item.ZAppCMF_afterAdd( safeStorage, newID ) ! def manage_afterAdd(self, item, container): """ restore XML from volitile attribute.. at this point 'self' is somewhat bogus. It still has cached DataSkin attributes from its prior self. --- 262,282 ---- item.ZAppCMF_afterAdd( safeStorage, newID ) ! def ZAppRecusionLock_checkSet(self): ! """ ! check for already being in manage_afterAdd() ! """ ! if getattr(self,'_v_in_manage_afterAdd',0): ! return 0 ! else: ! self._v_in_manage_afterAdd = 1 ! return 1 ! ! def ZAppRecursionLock_clear(self): ! """ ! clear the recursion lock. ! """ ! del self._v_in_manage_afterAdd ! ! def ZAppBase_manage_afterAdd(self, item, container): """ restore XML from volitile attribute.. at this point 'self' is somewhat bogus. It still has cached DataSkin attributes from its prior self. *************** *** 271,282 **** safeStorageID = getattr(self, '_v_safeStorageID','') newID = self.calcPathID() - - ZApp_LOG("_manage_afterAdd: " + self.getId() + ":" + safeStorageID + ":_v_in_manage_afterAdd:" + `getattr(self,'_v_in_manage_afterAdd',0)`, dbug_level) ! if getattr(self,'_v_in_manage_afterAdd',0): ! return ! else: ! self._v_in_manage_afterAdd = 1 ! if safeStorageID: mdm = self.getMiscDataSpecialist() --- 285,296 ---- safeStorageID = getattr(self, '_v_safeStorageID','') newID = self.calcPathID() ! checkRecursion = self.ZAppRecusionLock_checkSet() ! ! ZApp_LOG("_manage_afterAdd: " + self.getId() + ":" + safeStorageID + ":_v_in_manage_afterAdd:" + `checkRecursion`, dbug_level) ! ! if not checkRecursion: ! return checkRecursion ! if safeStorageID: mdm = self.getMiscDataSpecialist() *************** *** 291,298 **** get_transaction().commit(1) ! SkinnedFolder.manage_afterAdd(self, item, container) ! ZApp_Base.manage_afterAdd(self, item, container) ! del self._v_in_manage_afterAdd def copyObjectRelations(self, theObjectRelations): --- 305,321 ---- get_transaction().commit(1) ! return checkRecursion ! def manage_afterAdd(self, item, container): ! """ ! Do manage_afterAdd ! """ ! checkRecursion = self.ZAppBase_manage_afterAdd(item, container) ! ! if not checkRecursion: ! SkinnedFolder.manage_afterAdd(self, item, container) ! ZApp_Base.manage_afterAdd(self, item, container) ! ! self.ZAppRecursionLock_clear() def copyObjectRelations(self, theObjectRelations): *************** *** 314,320 **** --- 337,366 ---- extendProperties(ZApp_CMFBase, props) + class ZApp_CMF_FSFolder( ZApp_CMFBase): + """ + Folder with special skinnable PUT hook to handle ZApp media. + """ + meta_type = 'ZApp CMF Media Folder' + + _properties=({'id':'title', 'type': 'string', 'mode':'w'}, + {'id':'preferredMediaType','type':'string','mode':'w'}, + ) + + class_default_for_preferredMediaType = 'ZApp CMF Image' + + def PUT_factory( self, name, typ, body ): + """ + if it's an image, create our preferred media type to handle it. + """ + if typ.startswith('image') or typ.startswith('application'): + self.invokeFactory( self.preferredMediaType, name ) + obj = aq_base( self._getOb( name ) ) + self._delObject( name ) + return obj + class ZApp_CMF_FSObject( ZApp_CMFBase ): meta_type = 'ZApp CMF FSObject' + isPrincipiaFolderish = 0 _custom_skin_scripts = ("WITH SELF COMPUTE portal_object_id=_.getattr(self, 'zapp_portal_id')", *************** *** 322,329 **** "WITH SELF COMPUTE fs_object_relpath='%s/%s/%s' % (self.getPhysicalPath()[1], self.portal_object_id, self.cmfdataid[1:].replace(',','/'))", "WITH SELF COMPUTE fs_object_url=self.findApplication().absolute_url() + '/fSystem/' + self.fs_object_relpath", ! "WITH SELF COMPUTE fs_root_object=self.findApplication().fSystem", "WITH SELF COMPUTE fs_object_path='%s/%s' % (self.fs_root_object.basepath, self.fs_object_relpath)", ) ! def zcmf_copyToCurrPath( self, oldSelf ): """ --- 368,478 ---- "WITH SELF COMPUTE fs_object_relpath='%s/%s/%s' % (self.getPhysicalPath()[1], self.portal_object_id, self.cmfdataid[1:].replace(',','/'))", "WITH SELF COMPUTE fs_object_url=self.findApplication().absolute_url() + '/fSystem/' + self.fs_object_relpath", ! "WITH SELF COMPUTE fs_root_object=self.getFSRoot()", "WITH SELF COMPUTE fs_object_path='%s/%s' % (self.fs_root_object.basepath, self.fs_object_relpath)", + "WITH SELF COMPUTE fs_container=self.getCurrFolder()", + "WITH SELF COMPUTE fs_object=self.getFSObject()", ) ! ! ! def getFSRoot(self, app=None): ! """ ! get root filesystem object. ! """ ! if app is None: ! app = self.findApplication() ! return app.getFSystemObject() ! ! def getCurrFolder(self): ! """ ! get the 'folder object' that contains me ! """ ! currFolder = self.fs_root_object ! path = self.getPhysicalPath() ! portal = self.portal_object ! ! for folder in path[1:-1]: ! if folder in currFolder.objectIds('Folder'): ! fsFolder = getattr(currFolder, folder, None) ! else: ! currFolder.manage_addFolder(folder) ! fsFolder = getattr( currFolder, folder, None) ! ! if not fsFolder: ! raise RuntimeError, "Can't create folder!" ! ! currFolder = fsFolder ! ! return currFolder ! ! def getFSObject(self): ! """ ! return the Filesystem based object that holds my 'data'. ! """ ! ! if self.getId() in self.fs_container.objectIds(): ! theFSObject = getattr(self.fs_container, self.getId(), None) ! else: ! theFSObject = None ! ! return theFSObject ! ! 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) ! fileObj = getattr(self.fs_container, newID, None) ! 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) ! ! return oldID, newID, newTitle ! ! def index_html(self, REQUEST=None, RESPONSE=None): ! """ ! render image. ! """ ! fsObj = self.fs_object ! return fsObj and fsObj.index_html(REQUEST=REQUEST, RESPONSE=RESPONSE) ! ! 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) ! ! 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 ): """ *************** *** 381,384 **** --- 530,573 ---- extendProperties(ZApp_CMF_FSImage, []) + from Products.CMFDefault.Image import Image + + class ZApp_CMF_ZODBImage( ZApp_CMFBase, Image): + + meta_type = 'ZApp CMF Image' + zapp_cmf_type = 1 + isPrincipiaFolderish = 0 + + __implements__ = ( + Image.__implements__, + ) + + + manage_options = ( + { 'label' : 'Dublin Core' + , 'action' : 'manage_metadata' + } + ,) \ + + SkinnedFolder.manage_options + + class_default_for_copyable = 0 # make these guys default to 'not copyable' + + _primaryKeyStringSize=255 # allow for a pretty rediculous size... + _primaryKeyGenerator='self.calcPathID()' + _insertQueryPrefix = 'self.checkDups() and ' + + displayCustomUpdate_pt = PageTemplateFile('zpt/CMF_displayRelatedObjects', globals()) + + def manage_afterAdd(self, item, container): + """ + Do manage_afterAdd + """ + checkRecursion = self.ZAppBase_manage_afterAdd(item, container) + + if not checkRecursion: + Image.manage_afterAdd(self, item, container) + ZApp_Base.manage_afterAdd(self, item, container) + + self.ZAppRecursionLock_clear() + from DateTime import DateTime *************** *** 400,406 **** 'meta_type' : ZApp_CMF_FSImage.meta_type, 'product': 'ZApp', ! 'description':'Image Content type based on ZApp objects', 'icon':'image_icon.gif', ! 'factory': 'addZAppCMFImage', 'immediate_view': 'zapp_image_edit_form', 'actions': ({'id': 'view', --- 589,595 ---- 'meta_type' : ZApp_CMF_FSImage.meta_type, 'product': 'ZApp', ! 'description':'Image Content type based on ZApp objects using LocalFS for filesystem storage', 'icon':'image_icon.gif', ! 'factory': 'addZAppCMFFSImage', 'immediate_view': 'zapp_image_edit_form', 'actions': ({'id': 'view', *************** *** 433,436 **** --- 622,668 ---- ), }, + {'id': 'ZApp CMF ImageFolder', + 'title':'', + 'meta_type' : ZApp_CMF_FSFolder.meta_type, + 'product': 'ZApp', + 'description':'Portal Folder for Images with ZApp PUT hook (defaults to create ZApp CMF Image objects)', + 'icon':'folder_icon.gif', + 'factory': 'addZAppCMFFSFolder', + 'immediate_view': 'zapp_cmf_object_edit_form', + 'filter_content_types' : 1, + 'allowed_content_types':('ZApp CMF Image',), + 'actions': ({'id': 'view', + 'name': 'View', + 'action': 'zapp_cmf_object_view', + 'permissions': (CMFCorePermissions.View,), + }, + {'id': 'edit', + 'name': 'Edit', + 'action': 'zapp_cmf_object_edit_form', + 'permissions': (CMFCorePermissions.ModifyPortalContent,), + }, + { 'id' : 'subobjects' + , 'name' : 'SubObjects' + , 'action': 'string:${object_url}/folder_contents' + , 'permissions' : (CMFCorePermissions.View,)}, + { 'id' : 'metadata' + , 'name' : 'Metadata' + , 'action': 'string:${object_url}/metadata_edit_form' + , 'permissions' : (CMFCorePermissions.ModifyPortalContent,), + }, + { 'id' : 'xml' + , 'name' : 'XML' + , 'action': 'string:${object_url}/zapp_cmf_xml_form' + , 'permissions' : (CMFCorePermissions.ManagePortal,) + , 'visible' : 1, + }, + { 'id' : 'relations' + , 'name' : 'Relationships' + , 'action': 'string:${object_url}/zapp_cmf_view_relations' + , 'permissions' : (CMFCorePermissions.ManagePortal,) + , 'visible' : 1, + }, + ), + }, {'id': 'ZApp CMF Content', 'title':'', *************** *** 441,444 **** --- 673,677 ---- 'factory': 'addZAppCMFObject', 'immediate_view': 'zapp_cmf_object_view', + 'filter_content_types' : 1, 'actions': ({'id': 'view', 'name': 'View', *************** *** 515,526 **** o.change() ! if klass not in [ZApp_CMFBase, ZApp_CMF_FSObject, ZApp_CMF_FSImage]: return o ! def addZAppCMFImage(self, id, title='', klass=ZApp_CMF_FSImage, useExisting=1): """ add a CMFImage object.. pass in the right class... """ - return addZAppCMFObject(self, id, title, klass, useExisting) --- 748,770 ---- o.change() ! if klass not in [ZApp_CMFBase, ZApp_CMF_FSObject, ZApp_CMF_FSImage, ZApp_CMF_FSFolder, ZApp_CMF_ZODBImage]: return o + def addZAppCMFFSImage(self, id, title='', klass=ZApp_CMF_FSImage, useExisting=1): + """ + add a CMF_FSImage object.. pass in the right class... + """ + return addZAppCMFObject(self, id, title, klass, useExisting) ! def addZAppCMFImage(self, id, title='', klass=ZApp_CMF_ZODBImage, useExisting=1): ! """ ! add a CMF_ZODBImage object.. pass in the right class... ! """ ! return addZAppCMFObject(self, id, title, klass, useExisting) ! ! def addZAppCMFFSFolder(self, id, title='', klass=ZApp_CMF_FSFolder, useExisting=1): """ add a CMFImage object.. pass in the right class... """ return addZAppCMFObject(self, id, title, klass, useExisting) + Index: __init__.py =================================================================== RCS file: /cvsroot/zapp/ZApp/__init__.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** __init__.py 15 Feb 2004 15:58:53 -0000 1.24 --- __init__.py 28 Mar 2004 22:14:47 -0000 1.25 *************** *** 55,64 **** context.registerBaseClass(ZApp_CMFBase.ZApp_CMFBase) context.registerBaseClass(ZApp_CMFBase.ZApp_CMF_FSImage) utils.ContentInit( 'ZApp CMF Content', ! content_types = (ZApp_CMFBase.ZApp_CMFBase, ZApp_CMFBase.ZApp_CMF_FSImage), permission = AddPortalContent, ! extra_constructors = (ZApp_CMFBase.addZAppCMFObject, ZApp_CMFBase.addZAppCMFImage), fti=ZApp_CMFBase.factory_type_information, ).initialize(context) --- 55,65 ---- context.registerBaseClass(ZApp_CMFBase.ZApp_CMFBase) context.registerBaseClass(ZApp_CMFBase.ZApp_CMF_FSImage) + context.registerBaseClass(ZApp_CMFBase.ZApp_CMF_FSFolder) utils.ContentInit( 'ZApp CMF Content', ! content_types = (ZApp_CMFBase.ZApp_CMFBase, ZApp_CMFBase.ZApp_CMF_FSImage, ZApp_CMFBase.ZApp_CMF_ZODBImage, ZApp_CMFBase.ZApp_CMF_FSFolder), permission = AddPortalContent, ! extra_constructors = (ZApp_CMFBase.addZAppCMFObject, ZApp_CMFBase.addZAppCMFFSImage, ZApp_CMFBase.addZAppCMFImage, ZApp_CMFBase.addZAppCMFFSFolder), fti=ZApp_CMFBase.factory_type_information, ).initialize(context) *************** *** 76,80 **** context.registerHelpTitle('ZApp Help') - from Products.CMFCore.DirectoryView import registerDirectory, registerFileExtension from Products.CMFCore.FSFile import FSFile --- 77,80 ---- Index: ZApp_RelationshipManager.py =================================================================== RCS file: /cvsroot/zapp/ZApp/ZApp_RelationshipManager.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ZApp_RelationshipManager.py 28 Oct 2003 20:27:03 -0000 1.5 --- ZApp_RelationshipManager.py 28 Mar 2004 22:14:47 -0000 1.6 *************** *** 298,301 **** --- 298,303 ---- rRoles = getattr(ob, rRolesID) + rItems.manage_changeProperties(zapp_spec_order='aRelationshipItems') # make sure it comes after 'Relationships' and 'RelationshipRoles' + if (leverSet == 'ZODB_Lever_Methods'): rItems.defaultRack.manage_setStorage(zclass='Products.ZApp.ZApp_RelationshipItem/ZApp_RelationshipItem', use_attrib='NO', load_attrib='') *************** *** 317,320 **** --- 319,324 ---- theApp.manage_changeProperties( specialistMetaTypes = oldList + [ZApp_RelationshipManager.meta_type]) + + if REQUEST: return self.manage_main(self,REQUEST,update_menu=1) |