88 lines
4.7 KiB
HTML
88 lines
4.7 KiB
HTML
<html>
|
|
<head>
|
|
<title><b>gen</b> - Getting started</title>
|
|
<link rel="stylesheet" href="appy.css" type="text/css">
|
|
</head>
|
|
|
|
<body>
|
|
<h1>What is gen ?</h1>
|
|
|
|
<p><b>gen</b> is a code <b>gen</b>erator that allows you write web apps without having to face and understand the plumbery of a given web framework. <b>gen</b> protects you. Concentrate on functionalities that need to be implemented: <b>gen</b> will fight for you against the low-level twisted machineries and will let you evolve in your pure, elegant and minimalistic Python world.</p>
|
|
|
|
<h1>Download and install</h1>
|
|
|
|
<p>As a prerequisite, your machine must be able to compile. If it is not the case, install the necessary packages. On Ubuntu, for example:</p>
|
|
|
|
<p class="code codePara">sudo apt-get install build-essential</p>
|
|
|
|
<p>Install Zope 2.9. On Unix/Linux, the easiest way to do that is to download the <a href="https://launchpad.net/plone/2.5/2.5.5/+download/Plone-2.5.5-UnifiedInstaller.tgz">Plone unified installer</a>, that includes Zope.</p>
|
|
|
|
<p class="code codePara">
|
|
tar xvfz Plone-2.5.5-UnifiedInstaller.tgz<br/>
|
|
cd Plone-2.5.5-UnifiedInstaller<br/>
|
|
./install.sh
|
|
</p>
|
|
|
|
<p>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, and a tiny subset of Zope, and the Python interpreter that was also included.</p>
|
|
|
|
<p>Install Appy. Download it <a href="https://launchpad.net/appy">here</a>, unzip it and install it in the Python interpreter previously mentioned. If you have installed Zope in its standard location at <span class="code">/opt/Plone-2.5.5</span>:</li>
|
|
|
|
<p class="code codePara">
|
|
unzip appy0.8.1.zip<br/>
|
|
mv appy /opt/Plone-2.5.5/Python-2.4.4/lib/python2.4/site-packages
|
|
</p>
|
|
|
|
<p>Create a symbolic link, in /usr/bin, of your Python interpreter.</p>
|
|
|
|
<p class="code codePara">ln -s /opt/Plone-2.5.5/Python-2.4.4/bin/python2.4 /usr/bin/python2.4</p>
|
|
|
|
<p>Create a Zope instance. A Zope instance is a web server that will listen for browser requests on some port. Launch the script named <span class="code">mkzopeinstance.py</span> that ships with Zope. The following lines of code create a Zope instance in <span class="code">/home/gdy/instances/RegInstance</span>.</p>
|
|
|
|
<p class="code codePara">
|
|
python2.4 /opt/Plone-2.5.5/bin/mkzopeinstance.py<br/>
|
|
[answer script's questions:]<br/>
|
|
Directory: /home/gdy/instances/RegInstance<br/>
|
|
[also: username and password of the admin]
|
|
</p>
|
|
|
|
<p>Type anything as username and password: Appy will ignore it and create user <span class="code">admin</span>, password <span class="code">admin</span>.</p>
|
|
|
|
<p>Your instance is ready! It will run on port 8080 by default.</p>
|
|
|
|
<h1>Create a webapp</h1>
|
|
|
|
<p>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 some event through the net. The administrator of the event will be able to consult and search registrations. He will also be able to retrieve a PDF version of every registration.</p>
|
|
|
|
<p>A Appy webapp is simply a Python package. So create a Python package, for example in <span class="code">/home/gdy/projets/Registration</span>.</p>
|
|
|
|
<p class="code codePara">
|
|
cd /home/gdy/projets<br/>
|
|
mkdir Registration<br/>
|
|
cd Registration<br/>
|
|
touch __init__.py<br/>
|
|
touch Registration.py<br/>
|
|
</p>
|
|
|
|
<p>File <span class="code">__init__.py</span> is required by Python, to tranform folder Registration into a Python package. File <span class="code">Registration.py</span> 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.</p>
|
|
|
|
<p class="code codePara">
|
|
# ------------------------------------------------------------------------------<br/>
|
|
<b>from</b> appy.gen <b>import</b> *<br/>
|
|
<br/>
|
|
# ------------------------------------------------------------------------------<br/>
|
|
<b>class</b> Registration:<br/>
|
|
root = True<br/>
|
|
creators = ['Anonymous', 'Manager']<br/>
|
|
<br/>
|
|
p = {'multiplicity': (1,1)}<br/>
|
|
applicantName = String(**p)<br/>
|
|
applicantEmail = String(validator=String.EMAIL, **p)<br/>
|
|
companyName = String(**p)<br/>
|
|
companyUrl = String(validator=String.URL, **p)<br/>
|
|
webappDescription = String(format=String.XHTML, **p)<br/>
|
|
companyDescription = String(format=String.XHTML, **p)<br/>
|
|
# ------------------------------------------------------------------------------<br/>
|
|
</p>
|
|
</body>
|
|
</html>
|