# $Id: Webtop.py,v 1.31 2002/08/30 16:49:34 tarmo Exp $ # # Copyright 2001, 2002 by Fle3 Team and contributors # # This file is part of Fle3. # # Fle3 is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # Fle3 is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with Fle3; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Contains class Webtop, which is the root object for users' webtops.""" __version__ = "$Revision: 1.31 $"[11:-2] import Globals #from Globals import Persistent, HTMLFile import AccessControl from common import reload_dtml, add_dtml #import TraversableWrapper import WebtopFolder import WebtopTrash from TraversableWrapper import TWFolder from common import perm_view, perm_edit, perm_manage, perm_add_lo # This object is the root of a user's webtop and should reside inside # the UserInfo object of the user. # # A webtop contains a clipboard folder, a trash folder and any # WebtopItems the user has created. WebtopItem is a superclass, and # actually the webtop will contain specific subclass instances, like # WebtopFolder, WebtopFile, WebtopLink and WebtopMemo. # class Webtop( WebtopFolder.WebtopFolder, ): """User's Webtop.""" meta_type = "Webtop" dtml_files = ( ('index_html' , 'Index page' , 'ui/Webtop/index_html'), ('wt_add_folder', 'Webtop folder', 'ui/Webtop/wt_add_folder'), ('wt_upload' , 'Upload file' , 'ui/Webtop/wt_upload'), ('wt_add_link' , 'Add link' , 'ui/Webtop/wt_add_link'), ('wt_add_memo' , 'Add memo' , 'ui/Webtop/wt_add_memo'), ('wt_view_memo' , 'View memo' , 'ui/Webtop/wt_view_memo'), ('wt_rename' , 'Rename' , 'ui/Webtop/wt_rename'), ('wt_preferences','Preferences' , 'ui/Webtop/wt_preferences'), ('fle_html_header', '', 'ui/Webtop/fle_html_header'), ('fle_form_header', '', 'ui/Webtop/fle_form_header'), ) security = AccessControl.ClassSecurityInfo() def __init__(self): """Construct the webtop root object.""" self.__id_counter = 0L self.toplevel=1 for tup in self.dtml_files: add_dtml(self, tup) security.declarePrivate('manage_afterAdd') def manage_afterAdd(self, item, container): """Create trash and clipboard and call superclass initialization code.""" WebtopFolder.WebtopFolder.__init__(self, None, 'webtop') self.id = 'webtop' WebtopFolder.WebtopFolder.manage_afterAdd(self, item, container) self._setObject('trash', WebtopTrash.WebtopTrash()) self._setObject('clipboard', TWFolder()) from common import roles_admin, roles_staff, roles_user self.manage_permission(perm_manage, roles_admin, 0) self.manage_permission(perm_edit, roles_admin+('Owner',), 0) self.manage_permission(perm_view, roles_user, 0) security.declareProtected(perm_manage, 'reload_dtml') # No additional comments. def reload_dtml(self, REQUEST=None): """Reload dtml file from the file system.""" reload_dtml(self, self.dtml_files) if REQUEST: self.get_lang(('common',),REQUEST) return self.message_dialog( self, REQUEST, title=REQUEST['L_dtml_reloaded'], message=REQUEST['L_dtml_files_reloaded'], action='index_html') security.declarePrivate('generate_id') def generate_id(self): """Return a unique (within this webtop) id. These ids are used for any and all WebtopItems created instead of their visible names so we avoid any problems with visible name conflicts and can use more complex visible names for items.""" self.__id_counter += 1L return "wt"+str(self.__id_counter) security.declarePrivate('get_clipboard') def get_clipboard(self): """Returns a reference to the clipboard.""" return self.clipboard Globals.InitializeClass(Webtop) # EOF