[ZDP] Management tabs in Folder sub-class

Steve Spicklemire steve@estel.uindy.edu
Sat, 6 Mar 1999 08:41:55 -0500 (EST)


* How do I add management tabs to my folder sub-class?
   
   If you subclass 'OFS.Folder.Folder' to build a folderish object, you
   may want to keep around the old Folder management tabs, but add some
   of your own as well. This can be done by mucking with the Folder class
   'manage_options' attribute. One problem is that you might want your
   own custom 'manage_main' but the FolderClass uses 'manage_main' for
   displaying the contents of the folder. Here is what I did for my
   EMarket product:
   
   Look at Folder's manage_options
   
   >>> for option in Folder.manage_options:        
   ...     print option 
   ... 
   {'label': 'Contents', 'target': 'manage_main', 'action': 'manage_main'}
   {'label': 'Properties', 'target': 'manage_main', 'action': 'manage_propertiesForm'}
   {'label': 'Import/Export', 'target': 'manage_main', 'action': 'manage_importExportForm'}
   {'label': 'Security', 'target': 'manage_main', 'action': 'manage_access'}
   {'label': 'Undo', 'target': 'manage_main', 'action': 'manage_UndoForm'}
   {'label': 'Find', 'target': 'manage_main', 'action': 'manage_findFrame'}
   
   
   Notice that the "Contents" tab calls Folder's manage_main attribute. Just
   rename that in your sub-class:
   
   with something like:
   
    manage_contents=OFS.Folder.Folder.manage_main
   
   and assign that to a different tab.  Here is the beginning of the MarketItem
   class from the EMarket product:
   
   class MarketItem(OFS.Folder.Folder):
       """A MarketItem """
   
       # Specify a name for the item type:
       meta_type='MarketItem'
   
       # Specify a relative URL for the icon used to display icons:
       icon='misc_/EMarket/marketItem'
   
       manage_contents=OFS.Folder.Folder.manage_main    # rename Folder's manage_main
       manage_main=HTMLFile('marketItemEdit', globals())
       manage_image=HTMLFile('marketItemImage', globals())
   
       # Specify definitions for tabs:
       manage_options=[
           {'label':'Attributes', 'action':'manage_main'},
           {'label':'ImageUpload','action':'manage_image'},
           {'label':'View',       'action':''},
           ]
   
       #
       # add in the options from the Folder class.... change
       # the 'action' for Contents to 'manage_contents'
       #
   
       for item in OFS.Folder.Folder.manage_options:
   
           if item['label'] == 'Contents':
               manage_options.append(item.copy())  # be sure to muck with a *copy*      
               manage_options[-1]['action'] = 'manage_contents'
           else:
               manage_options.append(item) 
   
   
--------------------------< cut here >----------------------------
Steve Spicklemire (317) 788-3313             steve@estel.uindy.edu
Dept of Physics and Earth-Space Science          NeXTmail Welcome!
University of Indianapolis		
1400 East Hanna Avenue, Indpls. IN, 46227