本文を読み飛ばす

Zope-Five 5-6: Productを作ってみる

Zope-Fiveを使って, \ productを作ってみましょう.5

さて, 今Productはしょぼい状態です. \ でもデータだけは準備しときます.

いろんな見え方する方がやる気がでますので.

今回はBrowserで作業を進めます

browserで http://localhost:8080/MyEvents/manage を入力し \ ZMIを表示します.

前回追加したDTML Documentがあるはずです.

各DTML Documentにpropertyを追加していきます. \ 例えば, ownerとcreatedを設定したとします.

owner:

string

created:

DateTime

次に, index.ptを修正します. この部分

<td class="title" tal:content="i.title">my event1</td>

これに, 追加したプロパティを追加します.

<td class="title" tal:content="i/title">my event1</td>
<td class="title" tal:content="i/user">user-name</td>
<td class="title" tal:content="i/created/">20xx/xx/xx</td>

これだけで, 簡単な採番台帳の完成です :D \ 登録にZMIへのアクセス権が必要ですが, \ userを作るなりすればちゃんと動作はできます.

ただし, 使い勝手は別ですが

container内のobjectをscan

Productファイルを変更していきます.

今回はiCal出力を実装してみます. \ いきなりHTMLではないのですが...

  • viewを登録する

iCalendarを使って情報整理

BrowserViewから出力

今回はここまで

今回は短いですがここまでです. \ 本来はSimpleItemからの派生物を \ 自プロダクト専用のデータ格納Objectとして \ 使うのがきれいなサンプルかもしれません.

私は便利(準備が面倒?)なのでいつも \ DTML Documentを使っています.

番外編1です. 今日は気になった点をメモ

エラー出力内容がよくわからないエラー

一度この状態になるとひたすらprintデバッグするはめになります.

私の場合はattribute errorでした.

2010-08-12 09:56:34 ERROR Zope.SiteErrorLog 1281574594.650.886937122589
http://localhost:8081/five/kmemo2/edititem.html
Traceback (innermost last):
  Module ZPublisher.Publish, line 116, in publish
  Module ZPublisher.BaseRequest, line 520, in traverse
  Module ZPublisher.HTTPResponse, line 727, in debugError
NotFound:   <h2>Site Error</h2>
  <p>An error was encountered while publishing this resource.
  </p>
  <p><strong>Debugging Notice</strong></p>

  Zope has encountered a problem publishing your object.<p>
Cannot locate object at: http://localhost:8081/five/kmemo2/edititem.html</p>
  <hr noshade="noshade"/>

  <p>Troubleshooting Suggestions</p>

  <ul>
  <li>The URL may be incorrect.</li>
  <li>The parameters passed to this resource may be incorrect.</li>
  <li>A resource that this resource relies on may be
      encountering an error.</li>
  </ul>

  <p>For more detailed information about the error, please
  refer to the error log.
  </p>

  <p>If the error persists please contact the site maintainer.
  Thank you for your patience.
  </p>

発見したエラー内容としては

def someone( self, req=None ):
    req.abc

もう一例

class View( BrowserView ):
  def __init__( self, context, request ):
    print self.obj
    self.obj = 1

これはテストをちゃんと作って行けばいいのかもしれません.

コメント

Comments powered by Disqus
宣伝: