############################################################################## # # MyFolder # # GPL # # # # # # ############################################################################## """MyFolder object Derived from basic Folder $Id: MyFolder.py,v 0.1 2001/11/30 10:26:52 tillea $""" __version__='$Revision: 0.1 $'[11:-2] from Acquisition import Implicit from Globals import Persistent from OFS import FindSupport, Folder, ObjectManager, PropertyManager # from AccessControl import Role from AccessControl import ClassSecurityInfo, getSecurityManager, Role from webdav import Collection from OFS.SimpleItem import Item from Globals import InitializeClass, DTMLFile, default__class_init__ manage_addMyFolderForm=DTMLFile('dtml/myfolderAdd', globals()) def manage_addMyFolder(self, id, title='', keywords=[], author='', createPublic=1, createSelection=1, createHome=1, createUserF=0, REQUEST=None): """Add a new MyFolder object with id *id* and global keywords *keywords* and author *author*. If the 'createPublic' and 'createUserF' parameters are set to any true value, an 'index_html' and a 'UserFolder' objects are created respectively in the new folder. You can specify certain keywords which are inserted into each Document inside this folder. You can specify an author which are inserted into each Document inside this folder. """ ob=MyFolder() ob.id=str(id) ob.title=title ob.keywords=[] for keyword in keywords: keyword=keyword.strip() if keyword != '' : ob.keywords.append(keyword) ob.author=author self._setObject(id, ob) ob=self._getOb(id) checkPermission=getSecurityManager().checkPermission if createUserF: if not checkPermission('Add User MyFolders', ob): raise 'Unauthorized', ( 'You are not authorized to add User MyFolders.' ) ob.manage_addUserFolder() if createPublic: if not checkPermission('Add Documents, Images, and Files', ob): raise 'Unauthorized', ( 'You are not authorized to add DTML Documents.' ) ob.manage_addDTMLDocument(id='index.htm', title=ob.id+' main frame') if createSelection: if not checkPermission('Add Documents, Images, and Files', ob): raise 'Unauthorized', ( 'You are not authorized to add DTML Documents.' ) ob.manage_addDTMLDocument(id=ob.id+'_sel.htm', title=ob.id+' left navigation frame') if createHome: if not checkPermission('Add Documents, Images, and Files', ob): raise 'Unauthorized', ( 'You are not authorized to add DTML Documents.' ) ob.manage_addDTMLDocument(id=ob.id+'_home.htm', title=ob.id+' home') if REQUEST is not None: return self.manage_main(self, REQUEST, update_menu=1) def getProperty(self, id, d=None): """Get the property 'id', returning the optional second argument or None if no such property is found.""" if self.hasProperty(id): if id == 'keywords' : safe_keywords=self.keywords self.keywords=[] for keyword in save_keywords: keyword=keyword.strip() if keyword != '' : self.keywords.append(keyword) return getattr(self, id) return d class MyFolder(Implicit, Persistent, ObjectManager.ObjectManager, PropertyManager.PropertyManager, Role.RoleManager, Collection.Collection, Item, FindSupport.FindSupport, ): """ MyFolder is derived from Folder and supports global keywords and author """ __implements__ = Folder meta_type='MyFolder' _properties=({'id':'title', 'type': 'string'}, {'id':'keywords', 'type':'lines', 'select_variable':'keywords'}, {'id':'author', 'type':'string', 'select_variable':'author'},) manage_options=( (ObjectManager.ObjectManager.manage_options[0],)+ ( {'label':'View', 'action':'index.htm', 'help' : ('MyFolder', 'MyFolder_View.stx')}, )+ PropertyManager.PropertyManager.manage_options+ Role.RoleManager.manage_options+ Item.manage_options+ FindSupport.FindSupport.manage_options ) # 'help' : ('MyFolder', 'MyFolder_View.stx'), # 'label':'Properties', 'action':'manage_propertiesForm'}, __ac_permissions__=() default__class_init__(MyFolder)