Make sure you are in the same directory as the impy

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: is going to plan so far, you should now have a basic state store of your own – you can give it any key/value pairs you like, and retrieve or unset them at a later date. The important thing for this exercise is that because this is being mediated by a web server, you can get and set these values from different programs; so you could set a value in one program, and get it back in another. This forms a basic infrastructure for the chat system you’re about to write. Before you start designing you program, there’s one more bit of foundation work to do; let’s make sure it’s possible to talk to the server programmatically using python. Make sure you are in the same directory as the ‘im.py’ file you downloaded earlier, and start up the python interpreter by typing ‘python’ at a command prompt. Enter the following lines carefully, pressing return between each one (and making sure you replace ~myusername with your user name!) import im server=im.IMServerProxy(’http://soba.cs.man.ac.uk/~myusername/IMServer.php’ ) If you’ve done this correctly, python shouldn’t be reporting any errors (you should know what a ‘server’ is… if you’re wondering what a ‘proxy’ is, look up ‘proxy pattern’ on Wikipedia). Now type: server[’pythonTest1’] = ’hello’ and then look at the contents of the server store using your browser; you should see that it’s associated ‘pythonTest1’ with ‘hello’, exactly as though you’d done this via a URL as before. 2 If you look at the source of the page you’ve just got back from your get operation, you’ll notice that it really is just t...
View Full Document

This document was uploaded on 02/10/2014.

Ask a homework question - tutors are online