Projects: Chula | Apple

Chula is a lightweight web framework written in Python

Chula is an MVC style framework that works by routing web requests thru mod_python to native Python objects

Download
Download v0.0.4
 Recommended version for: Linux/Mac/Unix
Chula Builds: Release Notes
bsd linux mac win32
Stable

Here is the basic flow thru the Chula stack:

Stack

Chula has the following dependancies:

  1. Apache2
  2. Mod_python

To use the advanced features of Chula you will also need:

  1. Memcache
  2. Postgresql
  3. Psycopg2
  4. Python-2.5
  5. Simplejson

How to install Chula on Linux, Mac, and Unix:

user# wget http://www.rockfloat.com/chula/Chula-0.0.4.tar.gz
user# tar zxvf Chula-0.0.4.tar.gz
user# cd Chula-0.0.4
user# sudo python setup.py install
user# python -c 'import chula; print chula.version'
**When an ebuild is available it will be posted

How to install Chula on Windows:

  1. Download: http://www.rockfloat.com/chula/Chula-0.0.4.win32.exe
  2. Double click on it
  3. Follow the promps
  4. Best of luck, I don't test on windows :)

How to get a basic environment configured:

** The snippets below are contrived, but: "cut and pasteable"

Brief explanation of what's about to happen:

The steps below will create the most basic Chula application, which consists of the following:
  1. Python package
  2. Python Apache handler
  3. Controller
  4. Apache vhost
This will be implemented by a single directory and two symlinks. The last step is to delete all three, leaving your system 100% clean. You also need to have the following, else these instructions will not work without modification:
  1. Apache and Mod_python installation
  2. Bash shell
  3. Memcached (unless you want to configure PostgreSQL, and import the session schema and what not)
  4. Sudo access (to create the two symlinks)
  5. Gentoo linux (customize the paths to your system)

1. Create a demo python package to hold your environment

user# cd /tmp
user# demo=$(readlink -f $(pwd)/chula-demo)
user# htdocs=$demo/apache/htdocs
user# mkdir -p chula-demo/{apache,site-packages}
user# pushd chula-demo/site-packages
user# touch __init__.py

** Normally you'd use a subdir inside site-packages named: "demo" or something

2. Temporarily register it with Python

user# pkg=/usr/lib/python2.5/site-packages/chulademo
user# sudo ln -s $demo/site-packages $pkg

3. Create the controller

user# cat <<EOL > demo.py # Then paste the lines below (including EOL):

from chula.www import controller

class Demo(controller.Controller):
    def index(self):
        return 'hello world'

    def test(self):
        return 'testing the test method'

EOL

4. Create an error controller

user# cat <<EOL > error.py # Then paste the lines below (including EOL):

from chula.www import controller

class Error(controller.Controller):
    def e404(self):
        return 'An http 400 occured'

    def e500(self):
        return 'An http 500 occured'

EOL

5. Create the Apache handler

user# cat <<EOL > apache_handler.py # Then paste the lines below (including EOL):

from chula import config
from chula.www import apache

@apache.handler
def handler():
    demo = config.Config()
    demo.classpath = 'chulademo'
    demo.error_controller = 'chulademo.error'
    demo.session_encryption_key = 'abc123'
    return demo

EOL

6. Create an Apache vhost named chula-demo.conf

user# cd ..
user# pushd apache
user# mkdir htdocs
user# cat <<EOL > chula-demo.conf # Then paste the lines below (including EOL):

Listen 8080
<VirtualHost *:8080>
 ServerName chula-demo
 DocumentRoot $htdocs
 AliasMatch ^(?!.*([.])).*$ $htdocs/PLACEHOLDER.py

 PythonAutoReload On
 PythonDebug On
 PythonEnablePdb Off
 PythonOptimize Off

 <Directory $htdocs/>
  Allow from any
  AddHandler mod_python .py
  PythonHandler chulademo.apache_handler
 </Directory>
</VirtualHost>

EOL

7. Temporarily register this vhost

user# vhost=/etc/apache2/vhosts.d/chula-demo.conf
user# sudo ln -s $demo/apache/chula-demo.conf $vhost

8. Review the files you just created

chula-demo
|-- apache
|   |-- chula-demo.conf
|   `-- htdocs
`-- site-packages
    |-- __init__.py
    |-- apache_handler.py
    |-- demo.py
    `-- error.py

9. Start services and test

user# sudo /etc/init.d/apache2 restart
user# sudo /etc/init.d/memcached restart

** Now you can try browsing to: index and test

10. Remove the demo (if you want)

** This step will uninstall the demo cleanly and completely:

user# cd ~/Desktop
user# rm -rf chula-demo
user# echo sudo rm $pkg
user# echo sudo rm $vhost

# If the above two look ok/safe...
user# sudo rm $pkg
user# sudo rm $vhost


Powered by Chula v0.0.5_alpha_02
Click here for printable version of this page

rockfloat.com
16.617060 ms