From patchwork Thu Feb 3 13:47:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guilherme Salgado X-Patchwork-Id: 81650 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 335BEB7130 for ; Fri, 4 Feb 2011 00:48:09 +1100 (EST) Received: from mail-gx0-f179.google.com (mail-gx0-f179.google.com [209.85.161.179]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id D0E41B70E7 for ; Fri, 4 Feb 2011 00:48:06 +1100 (EST) Received: by gxk21 with SMTP id 21so500830gxk.38 for ; Thu, 03 Feb 2011 05:48:02 -0800 (PST) Received: by 10.151.103.6 with SMTP id f6mr13132581ybm.70.1296740881912; Thu, 03 Feb 2011 05:48:01 -0800 (PST) Received: from [192.168.1.103] ([187.126.150.244]) by mx.google.com with ESMTPS id a79sm490847yhd.45.2011.02.03.05.47.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 03 Feb 2011 05:48:00 -0800 (PST) Subject: Re: Missing basedir/apps in sys.path? From: Guilherme Salgado To: Dirk Wallenstein In-Reply-To: <20110203110405.GE13486@zap> References: <1296674170.2552.31.camel@feioso> <20110203110405.GE13486@zap> Date: Thu, 03 Feb 2011 11:47:56 -0200 Message-ID: <1296740876.4280.59.camel@feioso> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Cc: patchwork@lists.ozlabs.org X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org On Thu, 2011-02-03 at 12:04 +0100, Dirk Wallenstein wrote: [...] > > > > --- a/lib/apache2/patchwork.wsgi > > +++ b/lib/apache2/patchwork.wsgi > > @@ -11,6 +11,7 @@ import sys > > > > basedir = os.path.dirname(__file__) > > sys.path.append(basedir) > > +sys.path.append(os.path.join(basedir, 'apps')) > > > > os.environ['DJANGO_SETTINGS_MODULE'] = 'apps.settings' > > import django.core.handlers.wsgi > > Looks good. > However, I find it a bit confusing to construct a path that relies on > the fact that this module is found through a symlink. I would hardcode > '/srv/patchwork' and '/srv/patchwork/apps' like in the mod_python That means one more place people will have to remember to change when deploying/moving an instance, so I don't think it's a good idea. > config. Or would it be possible to get rid of the symlink > '/srv/patchwork/patchwork.wsgi' when changing it in > apache2/patchwork.wsgi.conf and then optionally construct the paths > relative from the real location? Yes, it's possible to use the real path to patchwork.wsgi in the apache config and then have patchwork.wsgi construct the path from its real location, but using the symlink may be a good idea because it provides some flexibility in case there's ever a need to move patchwork.wsgi to a different place. That flexibility may never be used, though. This is what the diff looks like: diff --git a/lib/apache2/patchwork.wsgi b/lib/apache2/patchwork.wsgi index 0488b48..869bb9d 100644 --- a/lib/apache2/patchwork.wsgi +++ b/lib/apache2/patchwork.wsgi @@ -9,8 +9,10 @@ import os import sys -basedir = os.path.dirname(__file__) +basedir = os.path.join( + os.path.dirname(__file__), os.path.pardir, os.path.pardir) sys.path.append(basedir) +sys.path.append(os.path.join(basedir, 'apps')) os.environ['DJANGO_SETTINGS_MODULE'] = 'apps.settings' import django.core.handlers.wsgi diff --git a/lib/apache2/patchwork.wsgi.conf b/lib/apache2/patchwork.wsgi.conf index e99f8c6..3756e5a 100644 --- a/lib/apache2/patchwork.wsgi.conf +++ b/lib/apache2/patchwork.wsgi.conf @@ -16,5 +16,5 @@ -WSGIScriptAlias / "/srv/patchwork/patchwork.wsgi" +WSGIScriptAlias / "/srv/patchwork/lib/apache2/patchwork.wsgi" WSGIPassAuthorization On