Pylons

From FireSpeakerWiki
Jump to navigationJump to search

How to get Pylons set up....


Make a virtualenv

 cd /usr/local/pythonenv
 
 $ virtualenv --no-site-packages BASELINE
 $ virtualenv --no-site-packages PYLONS-1
 $ source PYLONS-1/bin/activate 
 (PYLONS-1)$ easy_install Pylons

Make the project

 (PYLONS-1)projects$ paster create -t pylons helloworld
 (PYLONS-1)projects$ cd helloworld
 (PYLONS-1)projects/helloworld$ paster controller hello

Put a serve.wsgi file into the project's base dir:

 import os, sys
 import site
 site.addsitedir('/usr/local/pythonenv/PYLONS-1/lib/python2.5/site-packages')
 os.environ['PYTHON_EGG_CACHE'] = '/projects/helloworld/python-eggs'
 
 from paste.deploy import loadapp
 
 application = loadapp('config:/projects/helloworld/development.ini')

Point to serve.wsgi with Apache:

 <VirtualHost *>
       ServerAdmin ...
       ServerName helloworld.example.com
       TransferLog ...
       ErrorLog ...
       WSGIScriptAlias / /projects/helloworld/serve.wsgi
       WSGIDaemonProcess helloworld.example.com processes=2 threads=15 display-name=%{GROUP} user=jonathan group=users
       WSGIProcessGroup helloworld.example.com
 </VirtualHost>

Also can make proxy via virtualhost:

       #ProxyRequests Off
       #Deny from all
       
       ...
       
       #ProxyPass / http://localhost:5000/
       #ProxyPassReverse / http://localhost:5000/
       #ProxyPreserveHost On
       #<Proxy *>
       #       Order deny,allow
       #       Allow from all
       #</Proxy>

This has to be called somewhere

$ python setup.py develop