一个简单的评论包。
zc.comment的Python项目详细描述
支持对象注释列表的简单包。
详细文档
评论用户界面
创建我们将使用的浏览器对象。
>>> from zope.testbrowser.testing import Browser >>> browser = Browser() >>> browser.addHeader('Accept-Language', 'test')
为了了解评论是如何工作的,我们将创建一个简单内容的实例 对象:
>>> browser.open('http://localhost/@@contents.html') >>> browser.getLink('[[zope][[top]]]').click() >>> browser.getLink('[[zc.comment][Content]]').click() >>> browser.getControl(name='new_value').value = 'number' >>> browser.getControl('[[zope][container-apply-button (Apply)]]').click()
让我们访问对象并单击“注释”选项卡:
>>> browser.handleErrors = False >>> browser.getLink('number').click() >>> browser.getLink('[[zc.comment][Comments]]').click()
我们发现尚未发表任何评论:
>>> '[[zc.intranet][No comments have been made.]]' in browser.contents True
我们添加一个新的多行注释:
>>> browser.getControl('[[zc.comment][New Comment]]').value = '''\ ... I give my pledge, as an Earthling ... to save, and faithfully defend from waste ... the natural resources of my planet. ... It's soils, minerals, forests, waters, and wildlife. ... '''>>> browser.getControl('[[zc.comment][Add Comment]]').click()
现在,我们得到一个表,显示带有日期、文本的注释, 以及用户:
>>> print browser.contents <... <th> ...[[zc.comment][comment_column-date (Date)]]... </th> <th> ...[[zc.comment][comment_column-principals (Principals)]]... </th> <th> [[zc.comment][comment_column-comment (Comment)]] </th> ... <td> 2005 11 14 12:00:55 -500 </td> <td> Unauthenticated User </td> <td> I give my pledge, as an Earthling<br /> to save, and faithfully defend from waste<br /> the natural resources of my planet.<br /> It's soils, minerals, forests, waters, and wildlife.<br /> ... <label for="form.comment"> <span class="required">*</span><span>[[zc.comment][New Comment]]</span> </label> ...<textarea class="zc-comment-text" style="width: 50ex; height: 6em;" cols="60" id="form.comment" name="form.comment" rows="15" ></textarea></div> ... <input type="submit" id="form.actions.41646420436f6d6d656e74" name="form.actions.41646420436f6d6d656e74" value="[[zc.comment][Add Comment]]" class="button" /> ...
现在,我们将添加另一条评论。
>>> browser.getControl('[[zc.comment][New Comment]]' ... ).value = 'another comment' >>> browser.getControl('[[zc.comment][Add Comment]]').click() >>> print browser.contents <... <th> ...[[zc.comment][comment_column-date (Date)]]... </th> <th> ...[[zc.comment][comment_column-principals (Principals)]]... </th> <th> [[zc.comment][comment_column-comment (Comment)]] </th> </tr> ... <td> 2005 11 14 12:10:18 -500 </td> <td> Unauthenticated User </td> <td> I give my pledge, as an Earthling<br /> to save, and faithfully defend from waste<br /> the natural resources of my planet.<br /> It's soils, minerals, forests, waters, and wildlife.<br /> <BLANKLINE> </td> </tr> ... <td> 2005 11 14 12:10:18 -500 </td> <td> Unauthenticated User </td> <td> another comment </td> </tr> ... <label for="form.comment"> <span class="required">*</span><span>[[zc.comment][New Comment]]</span> </label> ... ...<textarea class="zc-comment-text" style="width: 50ex; height: 6em;" cols="60" id="form.comment" name="form.comment" rows="15" ></textarea>... <input type="submit" id="form.actions.41646420436f6d6d656e74" name="form.actions.41646420436f6d6d656e74" value="[[zc.comment][Add Comment]]" class="button" /> ...
变化
0.1.0(2008-04-21)
- 初始版本
评论
comment包是向任何^{tt1}添加注释的简单方法$ Zope内容。日期时间和当前主体标记在 评论。注释体当前只是Unicode文本,但其目的是 稍后的HTML片段(“富文本”)。
包含当前主体需要交互,这就是我们 在我们使用这个系统之前需要设置。下面,我们设了一个假人 与虚拟参与者交互,创建一些 IAttributeAnnotatable,最后显示正在使用的系统。
为了创建参与,我们需要几个原则:
现在我们可以创建参与:
接下来我们需要使sute设置注释机制,因为 Comments适配器需要能够对调整后的对象进行注释:
现在,让我们确保所有可注释的对象都可以接收注释:
现在我们已经准备好了,让我们看看它是如何工作的。首先我们 需要一个简单的内容组件:
为了处理评论,我们现在必须注册一个新的 参与。在我们的例子中,alice想要创建一个注释:
我们可以通过适应IComments:
最初,组件是不可注释的,因为它不提供 正确的接口:
现在添加一条注释:
如您所见,不需要手动创建comments对象, 但只要把课文交上来就行了。显然添加了一条评论:
现在让我们确保数据设置正确:
现在我们以贝蒂的身份登录:
贝蒂也可以添加评论:
她的评论也被正确存储:
现在让我们确保如果多个参与者在交互中 所有人都会被抓到:
最后,请注意,我们只能添加Unicode文本作为有效注释:
如果愿意,您可以随时清除所有评论:
当然还有一些清理工作: