This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

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

http://k0s.org

Release History

Release History

0.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
commentator-0.1.tar.gz (5.0 kB) Copy SHA256 Checksum SHA256 Source Jan 24, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting