Rockfloat.com
"They say that life has no meaning, but I don't believe it"
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 v0.0.4
Recommended version for: Linux/Mac/Unix
Recommended version for: Linux/Mac/Unix
|
Chula Builds:
Release Notes
|
|
|---|---|
| Stable | |
Here is the basic flow thru the Chula stack:
Chula has the following dependancies:
- Apache2
- Mod_python
To use the advanced features of Chula you will also need:
- Memcache
- Postgresql
- Psycopg2
- Python-2.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
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'
How to install Chula on Windows:
- Download: http://www.rockfloat.com/chula/Chula-0.0.4.win32.exe
- Double click on it
- Follow the promps
- 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:- Python package
- Python Apache handler
- Controller
- Apache vhost
- Apache and Mod_python installation
- Bash shell
- Memcached (unless you want to configure PostgreSQL, and import the session schema and what not)
- Sudo access (to create the two symlinks)
- 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
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
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
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
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
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
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
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
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
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