Pyjamas Tutorial
This page covers the pyjamas tutorial, to be held Monday 29th. In particular, prerequisites for attendees are covered, so that they can get the most out of the session without spending time on setup. Software requirements are divided into three sections: 1) browser(s) 2) pyjamas web 2.0 compiler 3) server infrastructure and web server framework (django) (which is a little bit more than just installing one package)
The summary is that attendees are best advised to bring a unix-based system or to turn their non-POSIX-compliant into a unix-based system, even if that is by dual-booting it or installing a Virtual Machine. The absolute best system to bring is a debian-based one, by virtue of the fact that installation of the required software will be measured in minutes, not hours or days.
Hardware Requirements
The hardware requirements are really very modest, for smaller pyjamas applications. Netbooks, OLPCs with AMD Geode LX800s and even ARM-based UMPCs or smartphones are perfectly sufficient (as long as they have a webkit-based browser).
- Computer with minimum 128mb of RAM; 500mhz CPU or above.
- Networking (wired or wireless).
Software Requirements
These are the components that you should have preinstalled.
Regarding the (long list of) web browsers: unless the Web 2.0 Pyjamas application is to be designed and restricted to one browser, it is adviseable to install as many web browsers as possible, even under GNU/Linux. Debian-based users should look up ies4linux and also install a recent version of Wine. Amazingly, ies4linux does actually get IE5.5 and IE6 into a useable state (but not IE7. yet). The version of IEXPLORE.EXE that comes with recent versions of Wine successfully use Gecko as the back-end, but are NOT suitable: there are bugs in the implementation of XMLHttpRequest, and it is a critical requirement of the tutorial to have working AJAX functionality.
- One or more modern javascript-capable web browser such as:
- Gecko-based engines (Firefox 2, Firefox 3 or OLPC Sugar's "browser" activity)
- Internet Explorer (IE6, IE7, IE8)
- Opera
- Safari or other webkit-based browser (such as Nokia S60 mobile phone, Palm Pre, iPhone, Android, Google Chrome or pywebkitgtk's demobrowser.py).
- python 2.4 to 2.7 - python 3 is NOT supported for installation (or use).
The latest svn of Pyjamas, available from sourceforge: follow the links from http://pyjs.org to the sourceforge download. You will need the latest svn because it contains examples that will be followed in the tutorial.
- Optionally: Apache2 and mod_python or mod_wsgi modules
- Django - a recent version is better, but a 1.0 will do.
Django Evolution - http://code.google.com/p/django-evolution - if using the latest version, with python2.5, see this: http://code.google.com/p/django-evolution/issues/detail?id=101 and make the necessary simple two-line adjustment.
- python-simplejson
libjsonrpclib.tgz - http://lkcl.net/jsonrpclib.tgz
jsonrpc.py - http://groups.google.com/group/pyjamas-dev/files or also copy here http://lkcl.net/pyjamas/jsonrpc.py because google groups is taking a nap right now.
- python-egenix-mxdatetime
- python-sqlite3
- Optionally: python-mysqldb and MySQL Server
- Optionally: python-psycopg2 and PostgreSQL Server
You should also ideally, if unfamiliar with Django, have gone through the Django Tutorial, starting here: http://docs.djangoproject.com/en/dev/intro/tutorial01/ - gloss over it, spending as little time as possible but at least "get familiar" with Django, and have a working app at least by the end of tutorial03.
- Pay attention to setup and to how Models are created
- Follow through with but gloss over "admin"
- Follow through with but gloss over "templates"
- Pay attention to how to set up URLs, and to settings and the workings of views.
Programming with Pyjamas loads some initial static HTML and Javascript (the application) and from there onwards makes predominant use of JSONRPC and very little use of templates. This is just a side-effect of pyjamas being a Web 2.0 framework. By the end of the Django tutorial03 you will have enough code to be able to easily add JSONRPC views (using jsonrpc.py) during the pyjamas tutorial.
Debian / Ubuntu
Debian and Ubuntu is the easiest to install. Install the following packages using apt-get install:
- python2.5
- python-egenix-mxdatetime
- python-django
- python-pysqlite2
- subversion
If you wish, obtain a pyjamas 0.5p1 deb package, here, but bear in mind that you really should obtain the latest svn (as well) so that you have the examples that will be used in the tutorial.
http://lkcl.net/pyjamas/pyjamas_0.5p1-1_all.deb and install with dpkg -i
Optionally install these:
- apache-mpm-prefork
- libapache2-mod-wsgi
- libapache2-mod-python
- mysql-server-5.0
- python-mysqldb
- postgresql-8.3
- python-psycopg2
Remember that you will still need libjsonrpc.tgz and jsonrpc.py and also django-evolution.
Windows Users
Please remember that the tutorial will be about "How to use Pyjamas" and "How to use Pyjamas with Django and other Frameworks", not "How to spend time in a Pyjamas Tutorial installing Software On Windows", so please read the following, carefully, before deciding to bring along a Windows laptop.
The installation of pyjamas itself under Windows is straightforward, which is where it would be convenient for a Windows user to utilise windows-based python editing tools.
However, editing and compiling pyjamas apps is only half the story: the other critical part is a server-side framework. Deployment of web services is typically and easiest done using LAMP infrastructure, and it's the server-side components where, unless the user is particularly experienced at installation of Free Software stacks (LAMP), then for the purposes of the tutorial it is STRONGLY advised NOT to utilise Windows.
For Django, Apache2, Mysql or PostgreSQL, Windows users are pretty much on their own, unless they install cygwin. Under those circumstances, the software installation is very straightforward: Cygwin has equivalents to the package list above, and a simple search through the cygwin setup GUI will allow users to install the necessary server components and their dependencies.
Here is an issue that you will need to take care of if you choose to install Django under cygwin:
http://stackoverflow.com/questions/533125/how-to-integrate-django-and-cygwin
If you choose to install Django under Windows, you can follow the instructions here:
http://docs.djangoproject.com/en/dev/topics/install/
Again, however, you will still need to download libjsonrpc.tgz, jsonrpc.py, and django-evolution can only be obtained from http://code.google.com/p/django-evolution.
Alternatives are to dual-boot the Windows system for the purposes of the tutorial, or to install Virtual Machine software and install a Debian-based OS in it. You will then be able to use the python editing environment of your preferred choice, alongside being able to copy the compiled pyjamas code into a much more palatable and easier-to-deploy server environment.
MacOSX Users
MacOSX users are recommended to install http://macports.org which will allow them to automatically install software by package name, including dependencies. Compilation on dual-core 2ghz Mac systems is stunningly quick: allow half a day for installation.
NOT using macports, and trying to utilise existing macosx-pre-installed versions of python, apache2 etc., is NOT recommended for the tutorial, unless significantly experienced at LAMP installations on MacOSX.
One attendee has already tried using macports, and has found the installation of django to be successful. this is what he has done so far:
Install Django and all its dependencies (40 minutes):
$ sudo port install py25-django
During Django installation it may display the following message:
To fully complete your installation and make python 2.5 the
default,
please run
sudo port install python_select
sudo python_select python25
What is saying is that you should install a tool that let you change
the default python if you have several python versions installed in
your system. Chances are that now you have at least two pythons in
your Mac: the stock python and the one from macports. python_select
lets you choose which to use, so follow suit:
$ sudo port install python-select
$ sudo python_select python25
Install extra packages for the tutorial:
$ sudo port install py25-mx-base
$ sudo port install py25-simplejson
Download Django Evolution
$ svn checkout http://django-evolution.googlecode.com/svn/trunk/
django-evolution
Download jsonrpc.py
From http://groups.google.com/group/pyjamas-dev/files save the file:
jsonrpc.py
Still missing in this instructable is how to configure Django and
Django Evolution. I'll try to configure both of them in the next few
days. The rest of the packages should already be working as expected. Last resort is to install a Virtual Machine and install a debian-based OS.
Testing
If attendees wish to test the installation of pyjamas before the tutorial, follow the INSTALL.txt instructions (not necessary if the 0.5p1 .deb has been installed) and then: {{ cd examples ./buildall.sh }} Windows users should make that "python ./buildall.py".
Then, set up a web server to point to the examples directory - even this will do: {{
- python /usr/lib/python2.5/SimpleHTTPServer.py
}} and then open a web browser, pointing it at the examples. If you are using a dumb web server (e.g. SimpleHTTPServer.py) instead of e.g. Apache2, you will find that dynatable, jsonrpc and others which rely on e.g. php or CGI will not work, but all other examples will.
