This is the P2PU Archive. If you want the current site, go to www.p2pu.org!

Beginning Python Webservices

My recent threads

You haven't posted any discussions yet.

Recently updated threads

Class 4: Python part 2 and where we are now

Go back to: General discussion

Last night I finished up the basic Python + the Web lesson:

http://k0s.org/mozilla/craft/python.html

So at this point, you've seen several examples of web services
(albeit, primative ones) and have seen how WebOb makes web programming
easy.  As an important self-check, I would advise you to go through
the examples in this lesson and make sure you can run the code and
understand it.  Try poking at it, making it do different things.  Hit
it with your web browser.  Put a pdb in and look at the request
object.  We don't have a lab in this class, but consider this
unofficial lab work.  Its one thing for me to explain it in class, but
its really only by "getting your hands dirty" that any of this will
make sense.

Speaking of unofficial homework, as mentioned in class you should read
WebOb's homepage.  In addition to explaining how WebOb works, it is
pretty insightful about the web in general:

http://pythonpaste.org/webob/

Hopefully, after last class, this will make sense to you and you'll
start to realize how you can start using this to make services.

Oh, I forgot to mention, in addition to having python installed, you
should also have virtualenv installed (and possibly setuptools) as
well. Make sure you have these tools and know how to use them!  In
addition, you'll probably also want to have mercurial (hg) installed:

http://mercurial.selenic.com/

Its not absolutely required, but it will make life easy.

Next time we'll be going straight into templates:

http://k0s.org/mozilla/craft/templates.html

Specifically, we're going to cover genshi templates (my reason?  I
like genshi templates), but most templating languages are more or less
the same.  We're also going to cover PasteScript's filesystem
templates for python package creation and I'll sneak in a little more
about python packages there. We'll learn how to make a (admittedly,
really basic) "wiki" out of a few services.  If you can follow this,
you're doing really well!  If you want to look ahead, the completely
undocumented software is here:

http://k0s.org/hg/SimpleWiki

There will be another homework soon.  I'll try to grade your first
assignment when I can, but honestly, I'm utterly swamped, so if I
don't have fast turnaround there, I apologize.

Jeff

Pablo Olmos de Aguilera C.'s picture
Pablo Olmos de Ag...
Wed, 2010-09-29 22:20

Thanks for the post!, I'll try to look for everything before tomorrow at night (I'll do my best to be there).

Is there a log from the second part or it was only through skype?

Jeff Hammel's picture
Jeff Hammel
Tue, 2010-10-05 00:06

It doesn't look like anyone has posted the IRC log from Python part 2. Does anyone have that that wants to post it here?

karine lagaffe's picture
karine lagaffe
Sun, 2010-10-03 20:30

Hello, I have a hard time installing virtualenv. I looked into virtualenv tutorials but it didn't help (p.s. : I'm on windows vista). Here is what I did :

1) on the prompt line I go to C:\Python27> (the folder Python is installed in).
2) C:\Python27>easy_install virtualenv
3) I get the error message : 'easy_install' is not recognized as an internal or external command, operable program or batch file.

BTW, I also tried hg clone http://bitbucket.org/ianb/virtualenv but I get the same message. What is the problem?

Caley Woods's picture
Caley Woods
Mon, 2010-10-04 15:26

@Karine:

In order to use easy_install you've first got to install Setuptools. It's available at the cheese shop here: http://goo.gl/6Poi

Download the version of setuptools that coincides with your version of Python (Likely 2.7 judging by your above post). The download is already in an .EXE installer you should just be able to run it (might have to make sure you run with admin rights by right-clicking and "Run As Administrator" on the file once it's downloaded.

This should install SetupTools(easy_install) to your site-packages and let you then do "easy_install virtualenv" like you tried earlier.

About your problem cloning from bitbucket: The command "HG" refers to mercurial which is a source code control program. You can find details on installing Mercurial on windows here: http://goo.gl/gBvL

Once you've installed mercurial you can test it by opening a CMD prompt and doing "hg --version" and it should report back a version. Your "hg clone" command should also work after this.

As an aside you might try opening a CMD prompt and without changing directory to your python27 folder try the command "python --version" if this is successful you're good to go. If it fails you might try looking at the beginning of my blog post here http://goo.gl/Nvzv for details on setting the Python installation directory as part of your System PATH so that the command "python" is recognized from any directory in CMD prompt (similar to how dir, find, and ipconfig work).

Please let me know if you have any other questions.

Jeff Hammel's picture
Jeff Hammel
Mon, 2010-10-04 23:50

Thanks for the advice, Caley. You'll probably want to have setuptools and mercurial installed on your computer. While some of the software you'll be using for the course (e.g. webob_view) is available via the package index, its probably more illustrative to to download the source code. While my mercurial repositories have links to zip files of the code (see http://k0s.org/hg ), mercurial is a valuable tool and probably worth installing for any developer (as well as clients for other popular version control systems). Did you get this working, Karine?

karine lagaffe's picture
karine lagaffe
Tue, 2010-10-05 09:11

Thanks alot Caley for your help. Yes it finally works with easy install !
I didn't know I had to change the Setup PATH Variable (and where) and that setuptools had to be installed first.