On Fri, 2007-06-08 at 07:33 -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. > > The whole concept of Django is this portability, so it seems unlikely > that I should have to explicitly refer to each application. I was > expecting it to obtain the settings and location from the Apache > VirtualHost directive. For completeness this is as follows: > > <Location "/"> > SetHandler python-program > PythonPath "['/usr'] + sys.path" > PythonHandler django.core.handlers.modpython > SetEnv PYTHON_EGG_CACHE /tmp > SetEnv DJANGO_SETTINGS_MODULE prod.settings > PythonDebug On > </Location> > > It is highly likely that I've made a simple slip up, but at present I > can't see it. Any advice welcome
It sounds like you just need to tweak your Python path so that things inside the prod/ or test/ directory (in the appropriate case) are on the Python path. Something like PythonPath "['/usr/prod/'] + sys.path" is probably correct. Then "import promotions" will work if prod/promotions/ is a directory. Regards, Malcolm --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---