If you're trying to do this using Mako templates, here is a fully
functional 'demo' that you should be able to easily adapt to do
exactly what you're asking about.


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




On Sat, Jan 22, 2011 at 23:06, Zeynel <[email protected]> wrote:
> On Jan 22, 10:35 pm, Robert Kluin <[email protected]> wrote:
>> So, if you are getting 'type=' twice, did you think about trying:
>>   self.redirect("/dir?%s" % urllib.urlencode({ "type" :
>> self.request.get("dir_type") } ))
>
> Yes, actually I thought about that but I did not try it because I did
> not get
>
> /dir?type=type=tshirt
>
> but just /dir?type=type=
>
> without the url parameter. But I may be wrong so I will try. But now I
> am working on trying to make this work with templates as explained
> here: 
> http://stackoverflow.com/questions/4769063/how-do-i-pass-url-parameter-to-form-value
>
> Unfortunately, I have an irrational hatred for Django templates so I
> am trying to do this with Mako templates. Researching this I found an
> old answer of yours: 
> http://stackoverflow.com/questions/3938963/mako-templates-with-google-app-engine/3939208#3939208.
> Thanks again for that answer. At this point my template page is
> printing as text like this
>
> <�html> <�body> <�p>Render template<�/p> ${greeting} <�/body> <�/html>
>
> so I am going to try to fix that first and then try the urllib option.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to