[Zope] Master-detail database updates

Smith, Neil Neil.Smith@npower.com
Wed, 6 Feb 2002 11:50:49 -0000


Is there a best practice way of writing master-detail forms for database
inserts/updates with Zope?  I haven't been able to find any good examples in
the documentation or how-to's.

I have managed to get an html form to work for inserting/updating a master
table and two associated detail tables from the limited information I have
found, but what I have done seems a complete messy kludge.  

It has involved using znolk to generate the default forms for the master
table maintenance and then adding sql-methods to get the detail information
which I then put into list variables.  I loop round the list variables on
the update form to display all the detail lines and then loop round an extra
couple of times to generate empty detail lines to allow for additions of
detail.  I have another submit button on the form that basically just
redraws the form but adds some extra blank lines to the detail if they are
needed.  Finally when saving the information I have the update method do an
update of the master table data then delete all the associated detail table
data and then add back in all the detail from the form.

Although this works there are a number of things that I don't like about it,
the main one being the fact it deletes all the detail data and then adds it
back.  However, all the alternatives I could think of had their own
drawbacks.

Has anyone else been through the same sort of things?  Are there any
products that would help?  Are there better ways to do it using python
scripts and database packages/procedures (the database is Oracle 8i)?  Any
suggestions are welcome.

Neil
**********************************************************************
 
The information contained in this e-mail is confidential and intended only for the use of the addressee. If the reader of this message is not the addressee, you are hereby notified that you have received this e-mail in error and you must not copy, disseminate, distribute, use or take any action as a result of the information contained in it.
    
If you have received this e-mail in error, please notify postmaster@npower.com (UK 01384 275454) and delete it immediately from your system.
    
Neither Npower nor any of the other companies in the Innogy group from whom this e-mail originates accept any responsibility for losses or damage as a result of any viruses and it is your responsibility to check attachments (if any) for viruses.

Npower Limited
Registered office: Windmill Hill Business Park, Whitehill Way, Swindon SN5 6PB. Registered in England and Wales: number 3653277

This e-mail may be sent on behalf of a member of the Innogy plc group of companies.

**********************************************************************