[Zope] Managing manage-tabs

Nico de Boer nico@nfg.nl
05 Dec 2001 17:02:46 +0100


Hello,

I'm having a problem with my products managing tabs.

It is a folderish product. I want to create a mailform with this
product.

I have created a manage tab 'Form', which is made at initialization of
the product (with manage_addDTMLDocument). The tab 'Form' shows a
textarea  where the form can be made in html-code . But when I want to
save the changes I return to the manage tab 'Edit'. When I save the
changes I want to return to the tab 'Form'. Has this something to do
with manage_addDTMLDocument ?
It seems like a simple problem, but I can't fix it. Can anyone help me
out? 

Here is a snippet of my code:

import Globals
from Globals import DTMLFile, MessageDialog
from OFS.Folder import Folder
from OFS.DTMLDocument import *

import string, smtplib, re, urllib

FormMail_Add = DTMLFile('dtml/FormMail_Add', globals())

def manage_FormMail_Add(self, id, title='', formulier='', REQUEST=None):
    """constructor MailProduct"""
    self._setObject(id, FormMail(id, title, formulier))
    if REQUEST is not None:
	    return self.manage_main(self, REQUEST)

class FormMail(Folder): 
    """FormMail object."""
	
    meta_type = 'Mail Formulier'
    
    manage_options = (
	    { 'label': 'Edit', 'action': 'manage_main' },
	    { 'label': 'Form', 'action': 'manage_formulier' },
	    { 'label': 'View ', 'action': 'state_engine' },
	    ) 

##edit the sender, to, subject of the email form
    manage_formulier = DTMLFile('dtml/formulierEdit', globals())

##edit the html-coded form of the email form
    manage_main = DTMLFile('dtml/FormMail_Edit', globals())

    def __init__(self, id, title='', formulier=''):
        """Initialization MailProduct"""
        self.id = id
        self.title = title
        self.formulier = self.init_form()
        self.Add_Formulier()

    def manage_edit(self, title='', REQUEST=None):
        """
        Edits content of the MailForm
        """
        self.title = string.strip(title)
        if REQUEST:
            message= 'Wijzigingen bewaard.'
            return self.manage_main(self, REQUEST,
                                    manage_tabs_message=message)

    def Add_Formulier(self):
        """Add a formulier to the FormMail product"""
        self.manage_addDTMLDocument('form',title='Formulier',file=self.formulier)

    def Edit_Formulier(self, formulier='', REQUEST=None):
        """Edit the formulier"""
        self.formulier = self.safe_unquote(formulier)
        if REQUEST:
            message= 'Changes saved.'
            return self.manage_formulier(self, REQUEST, manage_tabs_message=message)