WSGI commenting middleware
To use
Make a factory wrapping your app in the commentator middleware. Currently, commentator only pickles comments. To the constructor of Commentator, pass a database (the path to the pickle) and a pattern. The pattern is in the form of
<URL pattern>#<xpath pattern> -> URL
The URL pattern is a python regular expression to match against the request’s PATH_INFO.
The xpath pattern is where you want to place the comments on the page. See http://www.w3schools.com/XPath/ for more about xpath expressions.
The URL is a python string template that is substituted for groups in the URL regular expression and element attributes in the found nodes. The element attributes are referenced by name (${id}, ${class}, etc) and the groups are referenced by number (${1}, …).
Example
A reference implementation is illustrated in the commentator.ini file. This uses the pattern:
commentator.pattern = (.*)#.//div[@id='comment_on_this'] -> ${1}
What this pattern says is
comment on every PATH_INFO (.*)
append the rendered content template to div[@id='comment_on_this']
reference the PATH_INFO as the canonical URL ${1}
To comment on every HTML page at the end of the body, you would use
commentator.pattern = (.*)#.//body -> ${1}
A more complex example is in the .ini file, commented out, for use with bitsyblog :
commentator.pattern = /blog/.*#.//div[@class='blog-entry'] -> /blog/${id}
This pattern says:
comment on all paths under blog
put the comments at the end of each div[@class='blog-entry']
get the URI from the div’s id, not from the PATH_INFO
TODO
This is very alpha. I’d be happy to work more on this if anyone wants it. A few outstanding issues:
fix weird lxml issue where you have to put .// for elements
allow commenting on multiple resources (multiple patterns per instance)
locking pickle files
fix couch….not sure what’s wrong
allow use of CSS classes, not just xpath
–
Metadata
Release files for commentator 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| commentator-0.1.tar.gz | 5.0 kB | Without provenance | Details for commentator-0.1.tar.gz |
Release files / commentator-0.1.tar.gz
| Download URL | commentator-0.1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0898f004849eaab1fab72b0235721961a3df9d82a45b70347258b4cc2f72a950
|
|
BLAKE2b-256 checksum How to use checksums |
d88c9519668b415d9bb7ccd4b56e00ec86d86b3049f7f68e1005b728a269e1c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for commentator 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.