|
DeveloperGettingStartedGuide
Guide for developers to get started with PubSubHubbub
Featured Also see:
PubHubSubBub Developer TutorialNote: the project and this document are hosted here: https://github.com/marianoguerra/pshb-example improvements and corrections are welcome! welcome, this document contains an example application written in python that will help you play with a pshb (pubsubhubbub from now on) hub and an application that publishes its content to it. this guide explains how to install a pubsubhubbub server in your computer so you can play with it, normally on a web application you would use a pshb compatible server like:
Requirements
Installinggit clone https://github.com/marianoguerra/pshb-example.git cd pshb-example bash setup.sh the first command will fetch the project from github, the third one will get some libraries needed for the example to run. note: answer "y" to sammy and "n" to all the other questions that the script does (we don't need those libraries) Runningnow we will start the example application called pleinu twice (so we can test the communication using the hub) and we will start a local pshb hub. open 3 terminals and run one comment on each one: google_appengine/dev_appserver.py src/ -p 8000 --datastore_path=/tmp/tubes1 google_appengine/dev_appserver.py src/ -p 8001 --datastore_path=/tmp/tubes2 google_appengine/dev_appserver.py pubsubhubbub/hub/ this commands asume that you are at the root of the pshb-example folder. Playingopen a browser tabs pointing to: http://localhost:8000/ click the signup link and create a new user.
I will create one called spongebob, you will have to change the username whenever you see it.
after the signup process click the login button and enter the user and password you just entered.
create a message and click send, the message should appear below.
now go to http://localhost:8000/atom/messages/from/spongebob/
you should see an atom feed with the message you just created. Publishingnow that we have a page that generates information we need to publish it on the hub. open a tab in your browser pointing to http://localhost:8080/ and click on the publish link near the bottom.
if you get an error remove the s from the https protocol in the address bar and refresh.
on the Topic field enter the url to the atom feed we saw before: http://localhost:8000/atom/messages/from/spongebob/
and click Publish, the page wont change, that's ok. Subscribingnow we need to subscribe one user from the other site (http://localhost:8001/) to the messages sent by our user. go to http://localhost:8001/ and create another user, I will call it patrick
in the main page of the hub (http://localhost:8080/) click on the subscribe like near the bottom enter http://localhost:8001/p/notify/patrick/ on the Callback field (change patrick for your username if you used another one) enter http://localhost:8000/atom/messages/from/spongebob/ on the Topic field (change spongebob for your username if you used another one)
click the "Do it" button, the page won't change, that's ok. Sending a messageGo to http://localhost:8000/ (login if you closed it) and send a message.
Now go to http://localhost:8001/ and refresh the page, you should see the messages published by the user in the other site.
Noteto make it work and avoid an exception I had to add a return statement at the beginning of the log_message function at google_appengine/google/appengine/tools/dev_appserver.py if you get that exception like this: in log_request
self.requestline, str(code), str(size))
File "/home/asd/pubsubhubbub/pshb/google_appengine/google/appengine/
tools/dev_appserver.py", line 3314, in log_message
if self.channel_poll_path_re.match(self.path):
AttributeError: DevAppServerRequestHandler instance has no attribute
'path'
edit the function to look like this: def log_message(self, format, *args):
"""Redirect log messages through the logging module."""
return
if self.channel_poll_path_re.match(self.path):
logging.debug(format, *args)
else:
logging.info(format, *args)you will have to set write permissions to the file to save it (chmod u+w dev_appserver.py)
you will have to restart the pshb server: google_appengine/dev_appserver.py pubsubhubbub/hub/ |
Just a note: Before one can see the tasks in the feed-pulls, one has to run the mappings task to accept the subscription of a topic to the hub.
Was able to get the demo up, but could not create content. Getting error: 127.0.0.1 - - [09/Oct/2009 13:14:50] "GET /files/json.js HTTP/1.1" 404 -
Hmm when trying to start ihasfriendz I get: python main.py
SyntaxError?: invalid syntaxSeems to be the decorators: @tubes.JsonClass?()
Did I miss a prereq or something?
Hi adam.oakman
I think that your problem is the version of python. What python version your use to run main.py?
Look that version to run pubsub is different to run main.py. In first case is python '2.5', in second is '2.6'. I believe that if you use this correct version to each situation, main.py will run fine.
There is a problem getting this demo to run under python 2.6. The error occurs when manually running the event-delivery task queue. The error:
TypeError?: character mapping must return integer, None or unicode
Is due to this "bug:" http://bugs.python.org/issue5285
sequence of actions starting from "components used" was different to me:
I hope that helps to smb :)
When we use GAE 1.2.4 the hub won't start. It needs atleast GAE 1.2.8 to start the hub. It will be helpful if you can update the guide.
GAE python toolkit must be run with python 2.5. I tried python 2.6 to go through the tutorial process. It gave error messages in some steps.
Traceback (most recent call last):
ImportError?: No module named simplejsonI ran through this demo successfully on Ubuntu 9.10 using the default installed python (2.6). But it requires latest version of GAE, as such:
wget http://googleappengine.googlecode.com/files/google_appengine_1.3.2.zip unzip google_appengine_1.3.2.zip
Then execute the hub service: python google_appengine/dev_appserver.py pubsubhubbub/hub/
Without coming across as a total moron, does this get installed to my local test server, or installed to my web server?
Any help appreciated :)
Using: python2.5 google_appengine/dev_appserver.py pubsubhubbub/hub/
It dies due pubsubhubbub/hub/dos.py. It tries to access offset_multi which is not part of the module 'memcache'.
Worked for me. Use Python 2.5 for demo. Deploying in production.
Is this app, with its default configuration, polling for feeds that do not ping the hub, e.g. regular feeds, non-pubsubhub aware?
I have one little problem, when running the "delivery" queue, it just wont work, I keep pressing the "run" button but it does nothing <_>
I tried in Ubuntu 10.4 server mode with python 2.6 and it run without a problem. I just have to change from localhost to the IP address of Ubuntu since the server is running in VMWARE Fusion. Great example and tutorial.
Gives
AttributeError?: DevAppServerRequestHandler? instance has no attribute 'path'on Debian 10.04, Python 2.6, App Engine 1.3.8
Neither downgrading python to 2.5 nor using app engine trunk fixes. Erratic behaviour with no error handling. Has put me off.
got it running with google_appengine_1.4.1.zip w/ python 2.6 on ubuntu. don't use a secret key with the example, because it will expose a bug and not push events.
you might want to update the URL link to suprfeedr 'getting started' article, it is at:
http://blog.superfeedr.com/pubsubhubbub/API/getting-started-with-pubsubhubbub/
Does anyone knows exactly how should i get started if i want to create custom services on the server? Actually i want to create a custom interface for the service, so i need to be able to know how to subscribe and when a new feed comes to extract it and display it somewhere else! It would be really helpful if someone can point out those, instead of searching the whole code. Thank you very much!!
I have followed the instructions and find that there are quite a few .js files missing from src/js directory..
Not sure if anyone else ran into this, but if I log into localhost:8000 and localhost:8001 using 2 users in 2 separate tabs in a single browser instance (Chrome in this case), it causes the web app to fail (and not be able to send messages). Using incognito window for one worked, so it's probably just a cookie issue. Figures I'd make a note in case anyone else but me gets confused on it.
After installing and setting up everything, I'm still missing req.js which I think is preventing me from logging in. Anyone have a fix?
If the file req.js is missing and you have the jQuery library, you can substitute the command to its functions with some jQuery functions. req is called from the file ui.js:
At the end, in src/templates/index.html you can remove line 61 <script src="/static/js/req.js"></script>