Changes between Version 2 and Version 3 of TracDev/AlternativeFrontends
- Timestamp:
- Mar 12, 2015, 5:43:42 AM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TracDev/AlternativeFrontends
v2 v3 1 = Alternative frontends =1 = Alternative frontends for development 2 2 3 == Alternative frontend: mod_python ==3 == Alternative frontend: mod_python 4 4 5 Virtualenv can alsobe used with Apache and mod_python, but as mod_python will be a system install it will not be aware of the virtualenv without some configuration. For development this is useful as one Apache can serve various development versions in a more permanent way. This method will use the system Python, but will add the libraries from the virtualenv.5 Virtualenv can be used with Apache and mod_python, but as mod_python will be a system install it will not be aware of the virtualenv without some configuration. For development this is useful as one Apache can serve various development versions in a more permanent way. This method will use the system Python, but will add the libraries from the virtualenv. 6 6 7 '''Step 1:''' Make a new frontend script that for instance can be stored in the virtualenv 'bin' directory. 8 9 {{{ 10 #!python 7 1. Make a new frontend script that for instance can be stored in the virtualenv `bin` directory. 8 {{{#!python 11 9 #myvirtualtrac.py 12 10 … … 17 15 from trac.web.modpython_frontend import handler 18 16 }}} 19 20 '''Step 2:''' Update Apache config to use this script - add or update options according to the default mod_python setup like for instance found in TracModPython. 21 22 {{{ 17 1. Update Apache config to use this script. Add or update options according to the default mod_python setup like for instance found in TracModPython. 18 {{{#!apache 23 19 # Extend the path so Apache will find your script on path 24 20 PythonPath "['/path/to/my/virtualenv/bin'] + sys.path" … … 28 24 }}} 29 25 30 == Alternative frontend: mod_wsgi ==26 == Alternative frontend: mod_wsgi 31 27 32 Using Apache, mod_wsgi is a very good alternative to mod_python. Setting this up follows the same pattern, but for development es cpecially there is one major advantage: It can quite easily be set up to auto-reload on code changes.28 Using Apache, mod_wsgi is a very good alternative to mod_python. Setting this up follows the same pattern, but for development especially there is one major advantage: It can quite easily be set up to auto-reload on code changes. 33 29 34 '''Step 1:''' Update a default TracModWsgi setup to make a deamonised process, and as of mod_wsgi 2.0 (this setup depends on >= 2.0) there is built-in support for custom paths and similar. Example of a full `VirtualHost` configuration: 35 36 {{{ 30 1. Update a default TracModWsgi setup to make a daemonised process, and as of mod_wsgi 2.0 (this setup depends on >= 2.0) there is built-in support for custom paths and similar. Example of a full `VirtualHost` configuration: 31 {{{#!apache 37 32 <VirtualHost *:80> 38 33 ServerName virtualtrac.local … … 66 61 </VirtualHost> 67 62 }}} 68 69 '''Step 2:''' Go to http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode and save the long Python script that follows the text 'Example code for such an automatic restart mechanism...'. Save it as `/path/to/my/virtualenv/bin/monitor.py` 70 71 '''Step 3:''' A basic WSGI frontend script, save as `/path/to/my/virtualenv/bin/virtualtrac.wsgi` 72 73 {{{ 74 #!python 63 1. Go to [mod-wsgi:ReloadingSourceCode#Monitoring_For_Code_Changes ReloadingSourceCode] and save the Python script as `/path/to/my/virtualenv/bin/monitor.py` 64 1. A basic WSGI frontend script, save as `/path/to/my/virtualenv/bin/virtualtrac.wsgi` 65 {{{#!python 75 66 76 67 import sys … … 78 69 79 70 import os 80 os.environ['TRAC_ENV_DIR'] = "/path/to/trac/project"71 os.environ['TRAC_ENV_DIR'] = '/path/to/trac/project' 81 72 # or, alternatively for multiple projects 82 73 #os.environ['TRAC_ENV_PARENT_DIR'] = "/parent/path/to/many/projects"