JZUG PageTemplate WG
tahara氏によるHOWTOがhttp://zope.jp/howto/ZPT01にあるのでそこを参照してください。
----------ファイル構成----------
/ディレクトリ内に
index_html(Page Template)
pyinsert(Python Script)
select(SQL Method)
insert(SQL Method)
----------index_html----------
<html>
<head>
<title tal:content="template/title">タイトル</title>
</head>
<body>
<form action="pyinsert">
お名前<input type="text" name="name"><br>
タイトル<input type="text" name="title"><br>
コメント<input type="text" name="comment"><br>
<input type="hidden" name="page" value="/">
<input type="submit">
</form>
<table border>
<tr>
<td>お名前</td>
<td>タイトル</td>
<td>コメント</td>
</tr>
<tr tal:repeat="item container/select">
<td tal:content="item/name">name</td>
<td tal:content="item/title">title</td>
<td tal:content="item/comment">comment</td>
</tr>
</table>
</body>
</html>
----------pyinsert----------
Parameter:name,title,comment,page
----------------------------
request = container.REQUEST
RESPONSE = request.RESPONSE
sql=container.insert
sql(name=name,title=title,comment=comment)
RESPONSE.redirect(page)
----------select----------
select * from hoge
----------insert----------
Argument:name title comment
--------------------------
insert into
hoge(
name,
title,
comment
)
values(
<dtml-sqlvar name type=string>,
<dtml-sqlvar title type=string>,
<dtml-sqlvar comment type=string>
)
とりあえず、こんなものです。talとかmetalの詳しい説明は明日以降に。。。
ちゃんと表示できていなかったので書きなおしました。
| Last edited Sun, 10 Sep 2006 04:13:04 +0900 | Edit this page |