0

This one is really really buggging me.

Will start by saying that everything is working perfectly on my local machine. On the server however, whatever I do ends up in a "Can not locate template for uri: ..."

On my local machine I use a Linux VM on Mac OS X. I have looked into case-sensitivity issues between file names. No dice.

I orignally had everything working by calling the files locally.

To confirm, I switched to using the mako.directories = app:templates config and moved my templates directory from inside my app.views package to a app:template folder—which is a new folder names in lowercase.

On this configuration wasn't working.

I decided to be more explict.

So I called my mako files by doing:

 @view_config(renderer='myapp:templates/template1.mak')
 def template1(self):
      pass

Still no dice.

Tried being explicit locally.

 @view_config(renderer='templates/template2.mak')
 def template2(self):
      pass

Still failing.

And of course, when using mako.directories in config, it still dosent work.

 @view_config(renderer='template3.mak')
 def template3(self):
      pass

Is there a way to hook into this to see the specific filepath being called? Something much larger than 'templates/template.mak'?

For reference these are what the URI int the Pyramid TopLevelException looks like respectivley:

Exception
=========
"Can not locate template for uri %r" % uri)
mako.exceptions.TopLevelLookupException: Can not locate template for uri
========

'app:templates/template1.mak    
'app.views:templates/template2.mak'
ovatsug25
  • 7,786
  • 7
  • 34
  • 48
  • Just starting at beginning. Are you sure server is using the same configuration file as local? Usually server is setup to use something like production.ini. I would print settings somehow to log and confirm mako.directories exists and is correct. – Ian Wilson Jun 15 '15 at 19:57
  • I guess asset configuration should work though. What are you deploying to? Something specialized like heroku? – Ian Wilson Jun 15 '15 at 20:00
  • @plantian - i have actually not been able to use assets in pyramids because ive been deployinh straight to nginx. this is a server im mananging. right now, making a clean clone as per bossman suggestions with new permissions that reflect my current user. pserve has been running with sudo because and were trying to use a same user for the pyenv – ovatsug25 Jun 15 '15 at 20:08

1 Answers1

0

I figured out why it's not working!

I run python setup.py install on my server before I load my Pyramid app. All the python source-code is moved to my site-packages folder in my VENV but (importantly) my MAKO files are not moved there.

When I run python setup.py develop, because my packages are installed as symlinks, my MAKO files still live in my project.

Thought the name would indicate otherwise, pyramid projects that use non python files (such as templates) can not be installed! They must be maintained in that develop state.

If we can run these with python setup.py develop, please indicate that to me in the comments! I may be missing something.

Edit 1:

This is going in the right direction but I'm not sure how to use it:

https://docs.python.org/2/distutils/setupscript.html#installing-package-data

(Edit 3): Including non-Python files with setup.py

Edit 2:

This cued me in Preparing a pyramid app for production

Community
  • 1
  • 1
ovatsug25
  • 7,786
  • 7
  • 34
  • 48