一个简单的评论包。
项目描述
一个简单的包,用于支持为对象添加评论列表。
详细文档
评论界面
创建我们将使用的浏览器对象。
>>> from zope.testbrowser.testing import Browser >>> browser = Browser() >>> browser.addHeader('Accept-Language', 'test')
为了了解注释如何工作,我们将创建一个简单内容对象的实例
>>> browser.open('https://127.0.0.1/@@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)
初始发布
项目详情
关闭
zc.comment-0.1.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2cc8d1f5b7adf1a7f297b3f5412a4ee3a1c00a65fb1f9bc3ac101c116082ab8e |
|
MD5 | 4a7172d8e8c029a9e418228345c8f14f |
|
BLAKE2b-256 | 6fc37a12a64dd555917ad7bd3ecdc5e7200b6ee0013770d4092b9724a5637508 |
评论
评论包是一种简单的方法,可以为任何 IAnnotatable Zope内容添加评论。日期时间和当前主体将被打印到评论中。评论正文目前是简单的Unicode文本,但计划稍后将其变为HTML片段(“富文本”)。
包含当前主体的要求需要进行交互,这是我们在此处使用系统之前需要设置的内容。下面,我们使用虚拟的交互和参与者设置了一个虚拟的交互,创建了一些IAttributeAnnotatable内容,然后最终展示了系统的使用。
为了创建一个参与,我们需要一些主体
现在我们可以创建一个参与
接下来,我们需要确保注释机制已设置,因为评论适配器需要能够注释被适配的对象
现在让我们确保所有可评论的对象都可以接收评论
现在我们已经设置了一切,让我们看看它是如何工作的。首先我们需要一个简单的内容组件
为了与评论互动,我们现在必须注册一个新的参与。在我们的例子中,Alice想要创建一个评论
我们可以通过适配到 IComments 来访问对象的评论
最初,该组件不可评论,因为它没有提供正确的接口
现在让我们添加一个评论
如您所见,无需手动创建注释对象,只需传入文本即可。显然,已经添加了注释
现在让我们确保数据已正确设置
现在让我们以Betty的身份登录
Betty也可以添加注释
她的注释也已正确存储
现在让我们确保在多个参与者交互时,所有参与者都能被选中
最后,请注意,我们只能添加Unicode文本作为有效的注释
如果您愿意,您始终可以清除所有注释
当然,还需要一些清理