Tpd
From CommerceNet Wiki
The tpd library is a collection of event-notification tools.
The source code and project management have moved to Trac at https://microsear.ch/tpd/
In its initial version, there is a simple framework for clients using WATCH, PUBLISH and SUBSCRIBE verbs (called 'XGI', collectively) to interact with other clients using tpd instances as intermediaries. The tpd server is an HTTP server implementing one extra verb (WATCH) internally, and allowing others to be implemented by external clients (subscribed.sh is such a client, and implements the SUBSCRIBE verb.) Unmodified clients can be used by sending the special ;Method=WATCH (or similar) as a URI parameter (after the path, before any query string or subsequent parts.)
Contents |
[edit] tpd
Content POSTed to tpd can be fetched using specially-crafted mid: (Message-ID) URIs. To set the Message-ID when posting, include the Message-ID HTTP header in your POST. Subparts of form posts have cid: (Content-ID) URIs. These two special types of URIs can be prefixed with / and fetched from a tpd instance.
WATCH and GET on regular (non-mid:/cid:) http URIs returns a summary of all requests recorded by that tpd instance matching the URI parameters; globbing is allowed. There's a short HTML prologue, then for each matching message (POST, GET, etc) or message part a line similar to the following is printed.
<a href="/mid:17.1111542515.203.da39a3ee5e6b4b0d3255bfef95601890afd80709@127.0.0.1">localhost.localdomain GET / data:text/plain%3B%20charset%3Dutf-8, 2005-03-23T01:48:35.202Z/2005-03-23T01:48:35.211Z</a><br />
The difference between GET and WATCH is that WATCH leaves the response socket open and keeps streaming out new matching lines as matching requests occur.
- mid:17.1111542515.203.da39a3ee5e6b4b0d3255bfef95601890afd80709@127.0.0.1 — the Message-ID
- localhost.localdomain — the agency responsible for this message (override using the From: header)
- GET — the method that created this message
- / — the URI (name) associated with this message
- data:text/plain%3B%20charset%3Dutf-8, — a summary of the message (replaced with Message-ID for larger messages)
- 2005-03-23T01:48:35.202Z/2005-03-23T01:48:35.211Z — the lifetime of this message (as an ISO 8601 range)
[edit] game
There's a simple decentralized temperature-guessing game included with tpd. To start it, run "./game" from the tpd distribution directory. It will look something like this:
$ ./game Acting on behalf of user+10291@localhost >
Typing a temperature reading publishes it; when a published temperature reading is received, a summary is displayed:
temp 44 at time 1111701832.83; mean is 44
As a side-effect, "./game" started a tpd instance listening on port 19988. If you like, you can start several instances -- listening on different machines, different ports, or both -- and get a decentralized estimate by telling each "./game" instance the URIs of each tpd instance on the command line.
[edit] Files
- game — wrapper script to start up tpd.py, subscribed.sh, and game.sh; also runs Makefile
- game.cgi — non-XGI version of the temperature game for comparison
- game.sh — a decentralized subscription-based temperature-guessing game; give it a list of tpd URIs on the command line
- Makefile — pushes xgisheet.html to the URI http://127.0.0.1:19988/mid:xgisheet.html@localhost
- subscribed.sh — implements a SUBSCRIBE verb by watching WATCH traffic and using wget
- tpd.py — transfer protocol daemon, a simple notification server with support for a WATCH verb
- tpd.pickle — created by tpd.py; this is used to store anvils
- css.py — parser for cascading style sheets
- htmlentities.py — entity definitions HTML
- template/anvil.css — stylesheet for displaying cached HTML representations
- template/anvil_card.html — template for displaying a search result
- template/anvil_card.txt — plaintext template for displaying a search result
- template/anvil_exception.html — template for displaying error messages
- template/anvil_indentation.html — template for indenting subanvils
- template/anvil_onload.js — script for highlighting search terms and displaying a message box when displaying cached HTML representations
- template/tpd_feed.css — stylesheet for search results page
- template/tpd_feed_footer.html — footer for search results page
- template/tpd_feed_header.html — header for search results page
- utf_32.py, utf_32_2143.py, utf_32_3412.py, utf_32_be.py, utf_32_le.py, and utf_8b.py — codecs for various Unicode encodings not found in the standard Python distribution
- xgi — extensible gateway interface for asynchronous web applications
- xgisheet.html — a sample DHTML chat client for tpd; start it with a chat URI in the fragment identifier, like this: http://127.0.0.1:19988/mid:xgisheet.html@localhost#chat
- xgi.js — javascript support library for xgisheet.html
- add — advertisement daemon
- add.py — SellSideAds server
- template/adcopy.html — template for add.py
- ejax — event-driven javascript with asynchronous xml, a client-side content transclusion library
- ejax/ejax.js — client-side content transclusion library
- ejax/eminem.php — PHP tie-in for ejax example
- ejax/options.html — option-box content for ejax example
- ejax/test_src.html — example for ejax
- miffy — microformats editor, viewer and extractor (MiFEE?) (see http://www.microformats.org for information on microformats)
- combobox.html — holder page for miffy the microformat editor
- miffy.html — miffy sample data
- miffy.js — miffy, a javascript microformat editor and viewer that will use MFML for its internal data representation
[edit] Releases
- tpd-714.tar.gz -- version 714 of tpd and associated files [now branded "microsear.ch"]
- tpd-491.tar.gz -- version 491 of tpd and associated files
- tpd-270.tar.gz -- version 270 of tpd and associated files
- tpd-171.tar.gz -- version 171 of tpd and associated files
- tpd-30.tar.gz -- version 30 of tpd and associated files
- tpd-28.tar.gz -- version 28 of tpd and associated files
[edit] Repository Snapshot
- tpd-491.dump.bz2 -- versions 0…491 of tpd and associated files
[edit] Caveats
For those lucky few with Subversion repository access to the project, be sure to set your LANG environment variable to en_US.UTF-8 so that the files with Ångströ show up properly.
in .tcshrc: setenv LANG en_US.UTF-8 in .bashrc: export LANG LANG=en_US.UTF-8
Also, the project currently requries Python 2.4.1 (which is still not the default on Mac OS X) -- we are working to remove our (minor) dependence on 2.4-specific features, but we reserve the right to bring them back at any time.
To install dbxml (on Mac OS X):
- grab the distribution -- using the browser led to incomplete untar with stuffit, so do this from the command line:
- untar it in the directory it will stay in -- you cannot move it after this
- build it with the prefix /usr/local
- will take 30-45 mnutes on a dual G5
wget http://downloads.sleepycat.com/dbxml-2.2.13.tar.gz gzip -d dbxml-2.2.13.tar.gz gnutar -xf dbxml-2.2.13.tar cd dbxml-2.2.13/ sudo ./buildall.sh --prefix=/usr/local/ cd dbxml/src/python/bsddb3-4.3.3/ /usr/local/bin/python2.4 setup.py build sudo /usr/local/bin/python2.4 setup.py install cd .. sudo /usr/local/bin/python2.4 setup.py install
[edit] Future Plans
- a new scratchpad for the vision of how all these TPd parts will fit together
- and another for how TPd could be deployed as a public Web service
