[Zope-DB] dtml-if query
Greg Fischer
retheoff at gmail.com
Mon May 23 20:51:25 EDT 2005
Looks like you are kind of on track, try this...
<dtml-if "password_check == password">
<dtml-call updatemethod>
Article updated!
<dtml-else>
Password incorrect. Article not updated.
</dtml-if>
You have to go get the "password" variable somewhere though. Maybe
you need a quick zsql method that grabs it. Make one called "getpwd"
with arguments of "password" and "articleid". (you will run into
problems if you use the id column named "id",it will confilct with the
zope object id, unless you rename it in your zsql methods)
select password as pwd from articles where id = <dtml-sqlvar articleid type=int>
This will return a "pwd" variable in which to check. So, in complete
you might try this:
<dtml-if submit>
<dtml-in getpwd> <<< This is calling the zsql method and returning
the pwd value
<dtml-if "password_check == pwd">
<dtml-call updatemethod>
Article updated!
<dtml-else>
Password incorrect. Article not updated.
</dtml-if>
<dtml-else>
Error retrieving password data.
</dtml-in>
<dtml-else>
form stuff.... (in your form you will need the id as articleid)
<input type=hidden name=articleid value="<dtml-var id>">
</dtml-if>
There's probably a hundred different ways to get what you want, but I
hope this at least gets you going a bit.
Good luck!
Greg
On 5/23/05, Sungmook Kim <sungmook at yahoo.com> wrote:
> Hi,
> I'm working on a simple self-made board based upon
> mysqldb.
>
> The idea is that I want anonymous people allow to
> write with a password protection.
> Now I want them to be able to delete and edit
> articles.
> (but of course only with their password)
> I'd like to make a if query in addition to the code
> below so that the updatemethod is only called if the
> password the user enters equals to the one from the
> database.
>
> the db table has the following fields:
> id, title, article, author, password
>
> now i have to make a comparison prior to the
> updatemethod call.
>
> something like <dtml-if expr="password_check ==
> <dtml-var password>">
> <dtml-call updatemethod>
> </dtml-if>
>
> I'd like to do it with dtml but dont know how.
> Could anyone help?
>
> --
>
> <dtml-if submit>
> <dtml-call updatemethod>
> <h2>article edited!</h2>
> <p>
> <a href="list">List</a> or <a
> href="add">add
> another title</a>
>
> <dtml-else>
>
> <h2>Edit</h2>
> <dtml-in selectonemethod>
> <form action="edit" method="POST">
> <table border=0>
> <tr>
> <td>Title</td>
> <td><input name="title" width=30 value="<dtml-var
> name="title">"></td>
> </tr>
> <tr>
> <td>Article</td>
> <td><input name="article" width=30 value="<dtml-var
> name="article">"></td> </tr>
>
> <tr>
> <td>Password</td>
> <td><input name="password_check" width=30
> value=""></td> </tr>
>
> <tr>
> <td colspan=2 align=center>
> <input type="hidden" name="id" value=<dtml-var
> name="id">>
> <input
> type="submit" name="submit" value="Edit"> </td> </tr>
> </table>
> </form>
> </dtml-in>
> </dtml-if>
>
>
>
>
>
>
>
> ___________________________________
> 무료 1GB용량!, 더 이상 용량 고민없는 - 야후! 메일 (http://mail.yahoo.co.kr)
> 최신 휴대폰 정보, 벨소리, 캐릭터, 문자메세지 - 야후! 모바일 (http://kr.mobile.yahoo.com)
> 대한민국 블로그가 모인 곳! - 야후! 피플링(http://kr.ring.yahoo.com)
> _______________________________________________
> Zope-DB mailing list
> Zope-DB at zope.org
> http://mail.zope.org/mailman/listinfo/zope-db
>
--
Greg Fischer
1st Byte Solutions
http://www.1stbyte.com
More information about the Zope-DB
mailing list