A simple comment package.
Project description
A simple package to support a list of comments for an object.
Detailed Documentation
Commenting UI
Create the browser object we’ll be using.
>>> from zope.testbrowser.testing import Browser >>> browser = Browser() >>> browser.addHeader('Accept-Language', 'test')
To see how comments work, we’ll create an instance of a simple content object:
>>> 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()
Let’s visit the object and click on the comments tab:
>>> browser.handleErrors = False >>> browser.getLink('number').click() >>> browser.getLink('[[zc.comment][Comments]]').click()
We see that no comments have been made yet:
>>> '[[zc.intranet][No comments have been made.]]' in browser.contents True
Let’s add a new multi-line comment:
>>> 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()
Now, we get a table that displays the comment with it’s date, text, and the user who made it:
>>> 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" /> ...
Now, we’ll add another comment.
>>> 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" /> ...
CHANGES
0.1.0 (2008-04-21)
Initial Release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zc.comment-0.1.0.tar.gz
(13.1 kB
view details)
File details
Details for the file zc.comment-0.1.0.tar.gz
.
File metadata
- Download URL: zc.comment-0.1.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cc8d1f5b7adf1a7f297b3f5412a4ee3a1c00a65fb1f9bc3ac101c116082ab8e |
|
MD5 | 4a7172d8e8c029a9e418228345c8f14f |
|
BLAKE2b-256 | 6fc37a12a64dd555917ad7bd3ecdc5e7200b6ee0013770d4092b9724a5637508 |
Comments
The comment package is a simple way to add comments to any IAnnotatable Zope content. The datetime and current principals are stamped on to the comment. The comment body is currently simply unicode text but intended to be html snippets (“rich text”) at a later date.
The inclusion of current principals requires an interaction, which is what we need to set up before we can use the system here. Below, we set up a dummy interaction with dummy participants, create some content that is IAttributeAnnotatable, and then finally show the system in use.
In order to create a participation, we need a few principals:
Now we can create a participation:
Next we need to make sute the annotation mechanism is setup, because the comments adapter needs to be able to annotate the adapted object:
Let’s now make sure that all commentable objects can receive comments:
Now that we have everything setup, let’s have a look at how it works. First we need a simple content component:
In order to play with the comments, we now have to register a new participation. In our case, Alice wants to create a comment:
We can access the comments of an object by adapting to IComments:
Initially, the component is not commentable, because it does not provide the correct interface:
Let’s now add a comment:
As you can see it was not necessary to create the comments object manually, but simply pass in the text. Clearly a comment has been added:
Let’s now make sure that the data was set correctly:
Let’s now log in as Betty:
Betty can also add a comment:
And her comment is also correctly stored:
Let’s now make sure that if multiple participants are in the interaction that all of them get picked up:
Finally, note that we can only add unicode text as a valid comment:
If you like, you can always clear all comments:
And of course some cleanup: