[Zope-DB] need a suggestion regarding dtml method (and more...)

Laura McCord Laura.McCord at doucet-austin.com
Fri Apr 30 12:18:32 EDT 2004

I noticed that it is hard for me to deal with the dtml methods so maybe
I will take your advice and do zpt. 
Plus,  you were talking about using a reset button. Maybe that would be
a good route for me to take instead of using a cancel submit button, at
least for right now since I am not at all experienced with python

Thanks for your suggestions. 

 Hope you have a nice weekend too.


-----Original Message-----
From: Charlie Clark [mailto:charlie at egenix.com] 
Sent: Friday, April 30, 2004 11:08 AM
To: zope-db at zope.org; Laura McCord
Subject: Re: [Zope-DB] need a suggestion regarding dtml method (and


you really are having an intensive course in Zope! First of all: stick
ZPT and don't use DTML.

What you want to do is possible with <tal:condition="cancel"> or 
<tal:condition="edit"> but things get pretty complicated that way. It is

usually better to pass forms to a PythonScript which can then decide
is the correct action to do. This allows you to concentrate on
HTML code in your PageTemplate and procedural and functional code in

Whether a form is necessary in your case is a mute point. I think your  
current approach using links is fine - this way you either call up the
form or not but I am not quite sure why you would want to do this. In
forms the input type "submit" has two values which cause the browser to
something: "submit" is the default and causes the browser to POST or GET

the form to the URL declared in the "action"; "reset" causes the browser
clear any changes made to the form without sending anything to the

If you set the action of your form to a PythonScript you can ask the 
PythonScript to print out everything that was in the form.


<form action="myscript">
<input type="hidden" name="user" value="laura">

<input type="submit" name="action" value="submit">
<inout type="submit name="action" value="cancel">

with your script "myscript" looking like this:

request = context.REQUEST
print request.form
return printed

this could be extended in the future for your flow control

if request.action == "submit":
	return context.user_EditForm()
elif request.action == "cancel":
	return context.user_NoChanges()

Using PythonScripts to handle data passed from one object to another
you to use the power and simplicity of Python to do this and is one of
strengths of Zope. But it takes some getting used to.

Have a nice weekend!


On 2004-04-30 at 17:27:20 [+0200], Laura McCord wrote:
> Hi,
> I have a form that sends either an update or cancel variable to my 
> user_Update_html dtml method. The problem with the code is that it 
> does not do anything but show a blank grey screen if cancel was 
> selected and I want it to either tell the user that the update was 
> cancelled or go back to my index_html page. However, I tried revising 
> the code including a <dtml-else> or another <dtml-if> to check if the 
> value was "cancel" but haven't had much luck.
> Any suggestions would be appreciated.
> Thanks,
>  Laura
> The code looks like this:
> <html>
> <body bgcolor="#e7e7e7">
> <font color="#0a4f72" size="4">
> <dtml-if name="update">
> <dtml-try>
>  <dtml-call name="update_user_sql">
>  The user, <strong><dtml-var name="username">,</strong>
>  was successfully update in the database.
>  <dtml-except>
>  Sorry, the user was not updated in the database.
>  </dtml-try>
> </dtml-if>
> </font>
> </body>
> </html>
> _______________________________________________
> Zope-DB mailing list
> Zope-DB at zope.org http://mail.zope.org/mailman/listinfo/zope-db

On 2004-04-30 at 17:33:19 [+0200], Laura McCord wrote:
> Well I found a way to accomplish this but I did not use a submit 
> button. In fact, I don't think you can pass an argument through a 
> submit button. However, this is what I did:
> I created an image link where the image looks similar to a button that

> I created in photoshop. Then, I created an Edit Button and Cancel 
> button which you can see below. The first link contains the pass of 
> the userid which is what I wanted to do.
> <tr>
> <td>
> <a tal:attributes="href python: 'user_EditForm?userid=' + 
> str(userid)"><img src="edit_button.gif" alt="Edit"></a> </td>
> <td>
> <a tal:attributes="href python: 'index_html'"><img
> src="cancel_button.gif" alt="Cancel"></a>
> </td>
> Maybe this will help someone.
> -Laura

Charlie Clark

Professional Python Services directly from the Source
 >>> Python/Zope Consulting and Support ...
 >>> mxODBC.Zope.Database.Adapter ...
 >>> mxODBC, mxDateTime, mxTextTools ...

::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::

More information about the Zope-DB mailing list