TG 1.5.1 + Nginx + uWSGI templates path issues

48 views
Skip to first unread message

Rama

unread,
Feb 5, 2012, 12:00:38 AM2/5/12
to TurboGears
Hello,

thanks to Christoph I managed to setup everything to run TG 1.5.1 with
uWSGI
but I was about to deploy from staging to production until I faced
some genshi
templates paths issues:

Traceback for 'TemplateError: Search path for templates not
configured' :

http://dpaste.com/697664/

After setting genshi.search_path like this:

genshi.search_path = '/srv/staging/vodo-net/vodo_net/templates/'

I get 'TemplateNotFound: Template "vodo_net.templates.index" not
found' :

http://dpaste.com/697662/

I can't tell what changed, it kind of appeared all of a sudden without
any apparent reason.
It was working perfect until that point.

My versions are:

Genshi==0.6
TurboGears==1.5.1
uWSGI==1.0.2.1

Can anyone give me some light about this, please?

Let me know if you need further information from my setup.

Thanks in advance,
Rama

Christoph Zwerschke

unread,
Feb 5, 2012, 4:38:01 AM2/5/12
to turbo...@googlegroups.com
Am 05.02.2012 06:00, schrieb Rama:
> but I was about to deploy from staging to production until I faced
> some genshi templates paths issues

Do you have an __init__.py in your template directory?

Is uWSGI running under a user that has access to this directory?

> After setting genshi.search_path like this:
> genshi.search_path = '/srv/staging/vodo-net/vodo_net/templates/'
> I get 'TemplateNotFound: Template "vodo_net.templates.index" not
> found'

Is /srv/staging correct in production? Anyway, normally you should not
need to set genshi.search_path.

-- Christoph

Rama

unread,
Feb 5, 2012, 6:30:54 AM2/5/12
to TurboGears

Hey Christoph, thanks a lot for your quick response!

On 5 feb, 06:38, Christoph Zwerschke <c...@online.de> wrote:
> Am 05.02.2012 06:00, schrieb Rama:
>
> > but I was about to deploy from staging to production until I faced
> > some genshi templates paths issues
>
> Do you have an __init__.py in your template directory?

Yes, which is empty.

> Is uWSGI running under a user that has access to this directory?

Yes, and I even tried as root.

> > After setting genshi.search_path like this:
> > genshi.search_path = '/srv/staging/vodo-net/vodo_net/templates/'
> > I get 'TemplateNotFound: Template "vodo_net.templates.index" not
> > found'
>
> Is /srv/staging correct in production? Anyway, normally you should not
> need to set genshi.search_path.

Oops, I might have mixed something there, but even without /staging/
in middle
same thing happens.

I could offer you access to my virtual machine where I'm preparing
everything for deployment
if you would like to have a look directly. Maybe it'll make things
easier.

Send me your public key in that case and I'll reply a priv with the IP
address and such details.

Otherwise, let me know what else I could look at, please.

Thanks again,
-- Rama

> -- Christoph

Rama

unread,
Feb 5, 2012, 9:10:49 AM2/5/12
to TurboGears
Ok, we've found the problem but don't understand the reason.

It works if we start uwsgi from the project package like this:

(venv)rama@maindev:/srv/vodo-net/vodo_net$ uwsgi --ini /etc/uwsgi.ini

Do you know why this could be?
It would be good to fix or document this somehow.

We've spent long hours trying to fix it.

Thanks!
Rama

Chris Lambacher

unread,
Feb 5, 2012, 10:48:46 AM2/5/12
to turbo...@googlegroups.com
On Sun, Feb 5, 2012 at 9:10 AM, Rama <rama...@gmail.com> wrote:
Ok, we've found the problem but don't understand the reason.

It works if we start uwsgi from the project package like this:

(venv)rama@maindev:/srv/vodo-net/vodo_net$ uwsgi --ini /etc/uwsgi.ini

Do you know why this could be?
It would be good to fix or document this somehow.
Your package probably is not in the import path when you are running from outside the source directory. You would need to use one of the ways of adding it to the path. PYTHONPATH env variable is probably the easiest way that does not interfere with other installed things. If you are using completely separate virtualenv's for each project you could also do python setup.py develop
 
--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To post to this group, send email to turbo...@googlegroups.com.
To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.




--
Christopher Lambacher
ch...@kateandchris.net

Christoph Zwerschke

unread,
Feb 5, 2012, 11:01:31 AM2/5/12
to turbo...@googlegroups.com
Am 05.02.2012 16:48, schrieb Chris Lambacher:
> Your package probably is not in the import path when you are running
> from outside the source directory. You would need to use one of the ways
> of adding it to the path. PYTHONPATH env variable is probably the
> easiest way that does not interfere with other installed things. If you
> are using completely separate virtualenv's for each project you could
> also do python setup.py develop

You might get away with os.chdir() in your WSGI script, but python
setup.py develop/install is the proper solution.

See also
http://www.turbogears.org/1.5/docs/Deploy/NginxWsgi.html#using-a-virtual-environment

-- Christoph

Rama

unread,
Feb 5, 2012, 7:12:11 PM2/5/12
to TurboGears
> See alsohttp://www.turbogears.org/1.5/docs/Deploy/NginxWsgi.html#using-a-virt...
>
> -- Christoph

Thanks for the tips guys!
Now I have implemented an init script for uwsgi which specified the
PYTHONPATH and seems to be working properly.

Thanks a lot for your support and your work helping us run our site
with a proper production setup!

Feel free to have a look : http://vodo.net/

Next should be some performance tunning, I guess I need to post to
uWSGI list.
My concern is if I should run several instances of uWSGI to spread the
load across them on the same server
because trying to increase workers/processes to uwsgi daemons was
giving some error last time I tried it.

All the best!
Rama
Reply all
Reply to author
Forward
0 new messages