Yaml addressing and template with GAE is not working ?

19 views
Skip to first unread message

Emad Maleki

unread,
Nov 13, 2011, 11:01:38 AM11/13/11
to Google App Engine
you can check here also
http://stackoverflow.com/questions/8112722/yaml-addressing-and-template-with-gae-is-not-working-templatedoesnotexist-just

Problem :

I have problem with using template in Google App Engine by Python. the
thing is, when I address my static folder in Yaml, I can NOT access to
my template and when I remove it, it is access able. look at the
files.

this is my file structure
-src\
----\calc.py
----\main.py
----\index.html
----templ\
---------\calc.html
---------\js
---------\css

YAML:
handlers:
- url: /.* script: main.py

MAIN.PY
def main():
application = webapp.WSGIApplication([
('/', MainPage),
('/calc',Calc)
], debug=True)
wsgiref.handlers.CGIHandler().run(application)

Calc.py
class Calc(webapp.RequestHandler):
def get(self):
temp = os.path.join(os.path.dirname(__file__), 'templ/
calc.html')
outstr = template.render(temp, temp_val)
self.response.out.write(outstr)
THE RESULT IS : Status: 200 OK Content-Type: text/html; charset=utf-8
I can reach my file and the template addressing is working

BUTTTTTTT

when I add the following line to my YAML to access to my css and js
and so on. IT is not access able

YAML:

handlers:
- url: /.*
script: main.py

- url: /templ
static_dir: templ

or If i change order of them :
YAML:

handlers:
- url: /templ
static_dir: templ

- url: /.*
script: main.py
BOTH are NOT working and there is my error

Status: 500 Internal Server Error
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/
django_0_96/django/template/loader.py", line 72, in
find_template_source
raise TemplateDoesNotExist, name
TemplateDoesNotExist: calc.html


Please help me through this, there must be simple solution for it. I
really dont believe that GAE is that much fool....

Thank you in advanced

Tim Hoffman

unread,
Nov 14, 2011, 10:56:07 AM11/14/11
to google-a...@googlegroups.com
Static files (mapped by the static handler) are not accessible from your application code.

The static files are handled by different infrastructure.  You will need to deploy a second copy 
one for your application code access and one for static handler.

Its always been this way.  

Use a symlink in your project folder, rather than keeping two copies locally.

T

karthik valsatech

unread,
Nov 14, 2011, 11:08:05 AM11/14/11
to google-a...@googlegroups.com

T

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/tkoAtyiPkakJ.

To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Emad Maleki

unread,
Nov 24, 2011, 8:53:52 AM11/24/11
to Google App Engine
Reply all
Reply to author
Forward
0 new messages