Missing basedir/apps in sys.path?

Dirk Wallenstein halsmit at t-online.de
Thu Feb 3 22:04:05 EST 2011


On Wed, Feb 02, 2011 at 05:16:10PM -0200, Guilherme Salgado wrote:
> Hi there,
> I've just followed the instructions to deploy patchwork and everything
> seemed to work fine but when I went to /admin on my browser I got the
> following error:
>   TemplateSyntaxError: Caught ImportError while rendering: No module named patchwork
> Which seems to happen because templates reference the patchwork module
> directly (e.g. 'patchwork.views.') but in patchwork.wsgi only the
> basedir is added to sys.path, so you'd in fact have to reference that
> using 'apps.patchwork.views', so I was wondering if the patch below
> would make sense?
> Cheers,
> --- 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
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?


More information about the Patchwork mailing list