gen is a code generator that allows you write web apps without having to face and understand the plumbery of a given web framework. gen protects you. Concentrate on functionalities that need to be implemented: gen will fight for you against the low-level twisted machineries and will let you evolve in your pure, elegant and minimalistic Python world.
As a prerequisite, your machine must be able to compile. If it is not the case, install the necessary packages. On Ubuntu, for example:
sudo apt-get install build-essential
Install Zope 2.9. On Unix/Linux, the easiest way to do that is to download the Plone unified installer, that includes Zope.
tar xvfz Plone-2.5.5-UnifiedInstaller.tgz
cd Plone-2.5.5-UnifiedInstaller
./install.sh
Don't be afraid, you just installed a lot of lines of code, but we will only use a very small subset of it: absolutely no line from Plone, a tiny subset of Zope and the Python interpreter that was also included.
Install Appy. Download it here, unzip it and install it in the Python interpreter previously mentioned.
unzip appy0.8.1.zip
mv appy /opt/Plone-2.5.5/Python-2.4.4/lib/python2.4/site-packages
Create a symbolic link, in /usr/bin, of your Python interpreter.
ln -s /opt/Plone-2.5.5/Python-2.4.4/bin/python2.4 /usr/bin/python2.4
Create a Zope instance. A Zope instance is a web server that will listen for browser requests on some port. Launch the script named mkzopeinstance.py that is included with Zope. The following lines of code create a Zope instance in /home/gdy/instances/RegInstance.
python2.4 /opt/Plone-2.5.5/bin/mkzopeinstance.py
[answer script's questions:]
Directory: /home/gdy/instances/RegInstance
[also: username and password of the admin]
Type anything as username and password: Appy will ignore it and create user admin, password admin.
Your instance is ready! It will run on port 8080 by default.
Now, we need to write a webapp and install it into this instance. We will create a small webapp, called Registration, that will allow anonymous people to register to the Appy webapp awards and propose a webapp. The administrator of the awards will be able to consult and search registrations.
An Appy webapp is simply a Python package. So create a Python package, for example in /home/gdy/projets/Registration.
cd /home/gdy/projets
mkdir Registration
cd Registration
touch __init__.py
touch Registration.py
File __init__.py is required by Python, to tranform folder Registration into a Python package. File Registration.py will contain the definition of the class Registration: one instance of this class will be created and stored in the database every time a user registers itself though the web.
# ------------------------------------------------------------------------------
from appy.gen import *
# ------------------------------------------------------------------------------
class Registration:
root = True
creators = ['Anonymous', 'Manager']
p = {'multiplicity': (1,1)}
applicantName = String(**p)
applicantEmail = String(validator=String.EMAIL, **p)
companyName = String(**p)
companyUrl = String(validator=String.URL, **p)
webappDescription = String(format=String.XHTML, **p)
companyDescription = String(format=String.XHTML, **p)
# ------------------------------------------------------------------------------