On Fri, Jun 08, 2007 at 07:33:40AM -0700, Tipan wrote: > > I'm in the process of moving our projects onto production servers and > attempting to remove explicit references to the application name in my > files. I want to be able to run a full production and a staging > version on the same server (I've set this up with Apache VirualHosts). > Both versions will be updated via Subversion from the same repository > but I want only the settings files to be the only difference between > them. > > However, I'm struggling to get it working when I remove all explicit > project references from views.py and some other custom modules. > > For example, the two versions called Prod and Test are sitting in > separate directories, each with their own setting files. The settings > files and locations are defined in the VirtualHost definition. Both > sites work fine when I change the explicit references in both url.py > files and in the relevant views.py and modules > > >From the top level url.py I'd have: > urlpatterns = patterns('', > (r'^', include('prod.promotions.urls')), #(or > test.promotions.uls) > ... > In the url.py in promotions would be: > > from promotions.models import * > > urlpatterns = patterns('', > (r'^home/$', 'prod.promotions.views.home',), #(or > test.promotions.views.home) > .... > > Then in the Views.py I have to explicitly refer to:. > > from prod import settings #(or - > from test imprt settings) > from prod.promotions.models import * > from prod.promotions.form_defs import * > > I have tried to change the references to run without the prod or test. > e.g. from promotions.models import. But this results in an input > error. I've also played tunes with the PythonPath settings in Apache, > but again to no avail.
Assuming you have a directory layout like: /usr/local/lib/mysite/prod /usr/local/lib/mysite/test Currently, you would have a situation kind of like this: PYTHONPATH="/usr/local/lib/mysite:other:python:path:stuff" Which means you have to do this: from prod import xyz from test import abc However, if you re-structure a little bit: /usr/local/lib/mysite_prod/mysite urls.py settings.py promotions/ ... /usr/local/lib/mysite_test/mysite urls.py settings.py promotions/ ... And then set your Python paths differently: production: PYTHONPATH="/usr/local/lib/mysite_prod" development: PYTHONPATH="/usr/local/lib/mysite_test" Then you can do: from mysite import promotions And it will work correctly in both instances. -Forest
signature.asc
Description: Digital signature