Reputation: 21
What am I trying to achieve:
Below is the code I am trying to run from \mongodb\blog\blog.py
@bottle.route('/')
def blog_index():
cookie = bottle.request.get_cookie("session")
username = sessions.get_username(cookie)
return bottle.template('blog_template',username=username))
After running blog.py from terminal and browsing to localhost:8082 I get the below error:
Template 'blog_template' not found.
I had a similar problem last week which I fixed by changing the folder permissions to 777 (just to rule out permissions as the issue) but permissons are currently set to god on all sub folders to \mongodb and I still get the same issue.
The templates are all located in \mongodb\blog\views as specified in bottle.py documentation
currently permissions on that folder are as follows: (regulator is the user I am logged in with)
-rwxrwxrwx 1 regulator regulator 718 Mar 23 2015 blog_template.tpl
-rwxrwxrwx 1 regulator regulator 1211 Mar 23 2015 entry_template.tpl
-rwxrwxrwx 1 regulator regulator 113 Mar 23 2015 error_template.tpl
-rwxrwxrwx 1 regulator regulator 816 Mar 23 2015 login.tpl
-rwxrwxrwx 1 regulator regulator 581 Mar 23 2015 newpost_template.tpl
-rwxrwxrwx 1 regulator regulator 1454 Mar 23 2015 signup.tpl
-rwxrwxrwx 1 regulator regulator 368 Mar 23 2015 welcome.tpl
I'm positive this is a permissions based issue and that I have overlooked something pretty basic but since I have been troubleshooting this for last 3 hours I would appreciate some fresh eyes to give it look over.
What permissions need to be in place for bottly.py to work? Is this documented anywhere (ive looked through http://bottlepy.org/docs/ can could not find this info)?
--------------------EDIT-------------------
Since writing this I have also tried the following
I have recreated a new test project to test only the template parts folder structure is
test |_test.py |_views |__test.tpl
The code in test.py is as follows
from bottle import route, run, template @route('/hello') def hello(): ##return "<h1>Hello World!</h1>" output = template('test') return output run(host='0.0.0.0', port=8080)
Permissions
regulator@HP-EB8460p-UbGnome:/mongodb$ ls -l /mongodb/test/*
-rwxrwxrwx 1 root root 191 Jan 25 19:10 /mongodb/test/test.py
/mongodb/test/views:
total 4
-rwxrwxrwx 1 root root 141 Jan 25 19:12 test.tpl
and finally the .tpl folder
<!DOCTYPE html>
<html>
<head>
<title>Why wont I work!!</title>
</head>
<body>
<h1>THIS IS A TEST</h1>
IF YOU CAN SEE THIS THE TEST WORKS!!!
</body>
</html>
Upvotes: 2
Views: 383
Reputation: 8041
Maybe you didn't change the TEMPLATE_PATH?
bottle.TEMPLATE_PATH += './mongodb/blog/views' #change this to the place your templates are found in
I hope this helps
Upvotes: 2