instead of ### print the value of the variable merchandise_type
2011/1/22 Zeynel <azey...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> 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.
>
>
Robert
If Directory() is processed after DirectorySubmitHandler() you can
NEVER get the merchandise_type variable.
And it is possibly handled in another app instance.
dir_type = merchandise_type # remove this line
dir_type is never used in DirectorySubmitHandler()
------------------------------------
import urllib
self.redirect("/dir?%s" % urllib.urlencode({ 'type' :
self.request.get("dir_type") } )
app.yaml
--------
handlers:
- url: /makodemo.*
script: makodemo.py
login: admin
makodemo.py
-----------
#!/usr/bin/env python
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from mako.lookup import TemplateLookup
from mako import exceptions
class DemoMakoTemplateHandler(webapp.RequestHandler):
"""Simple demo using mako templates."""
def __init__(self, **kwargs):
webapp.RequestHandler.__init__(self, **kwargs)
self.template_values = {'message': ''}
def render(self, template_name, values=None):
"""Setup search paths, and render the template.
Any values passed in will be combined with
self.template_values, and passed to the template.
"""
directories = ['templates']
lookup = TemplateLookup(directories=directories)
template = lookup.get_template(template_name)
if values:
self.template_values.update(values)
try:
self.response.out.write(template.render(**self.template_values))
except:
self.response.out.write(exceptions.html_error_template().render())
def get(self):
"""Render the template."""
self.render("demo.mako")
def post(self):
"""Get the user's message then render the template again."""
message = self.request.get('message')
self.render("demo.mako", {'message': message})
def main():
application = webapp.WSGIApplication([('/makodemo', DemoMakoTemplateHandler)],
debug=True)
run_wsgi_app(application)
if __name__ == '__main__':
main()
demo.mako
---------
<html>
<head>
<title>Mako Demo</title>
</head>
<body>
<div>Last message was: ${ message }</div>
<form action="/makodemo" method="post">
<input type="text" name="message" value="${ message }"></input>
<input type="submit" name="doit" value="update"></input>
</form>
</body>
</html>
Make sure you've went through the app engine getting started and
really looked at how things work carefully. No matter which template
language you chose, be sure to review their docs too.
http://code.google.com/appengine/docs/python/gettingstarted/introduction.html
http://www.makotemplates.org/docs/
Robert
2011/1/23 Zeynel <azey...@gmail.com>: