[Zope] Basic application
Cliff Ford
Cliff.Ford at ed.ac.uk
Sat Oct 30 02:42:31 EDT 2004
I can't speak for a calendar, but I always use the same form for
addition and modification, and the same action script for processing. I
find it easiest to create and populate the form using a Python script,
especially if the form contains check boxes or select lists, where it is
important to preserve the stored settings for modification. Typically
the difference between add and mod is a simple if statement controlled
by some parameter passed to the form or the action script.
A form generation example:
if context.REQUEST.has_key('SerialNo'):
# get the previous values and put them in variables here
else:
# put default values in the variables here
# print the form here using the initialised variables
A form processing script example (for a database):
if context.REQUEST.action == 'Add':
context.addItemSQL()
else:
context.modItemSQL()
There are different ZSQL Methods for add and mod, but at least the add
and mod forms can't get out of sync.
Cliff
Eddy Ilg wrote:
> Hi,
>
> I very often have following problem and wanted to ask here about the
> best way to do it. Very many times I have a container folder (e.g.
> caldendar) with objects inside (e.g. a schedule entry of a calendar).
> The user can perform 4 basic actions on these objects:
>
> 1. Display them - this happens via index_html in the container folder
> 2. Create them - this happens via a dtml-document addEntry with a form
> The script then calls addAction
> 3. Modify them - this happens via a dtml-document modEntry
> The script then calls modAction
> 4. Delete them - this happens via a dtml-document delEntry
>
> I ususally put all this functionality in a ZClass to use it at several
> locations of a site.
>
> What I find very inconvinient is that I always have to write the
> addEntry and modEntry script. That is always two scripts that are very
> simmilar.
>
> I need ZClasses with functionality as above very often. Is there a
> better way to do it?
>
> Thanks
>
>
> Eddy
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
More information about the Zope
mailing list