Hi I modified simple google guestbook example to keep checkbox values. but I couldnt make it work truely here is my html: <html> <body> {% for greeting in greetings %} {% if greeting.author %} <b>{{ greeting.author }}</b> wrote: {% else %} An anonymous person wrote: {% endif %} <blockquote>{{ greeting.content|escape }}</blockquote>
{% endfor %} <input type="checkbox" name="option 1" {% if not greetings.opts or "option 1" in greetings.opts %}checked="1"{% endif %} /><span class="font90" style=" cursor:default;" >{{("Option 1")}} </span> <input type="checkbox" name="option 2" {% if not greetings.opts or "option 2" in greetings.opts %}checked="1"{% endif %} /><span class="font90" style=" cursor:default;" >{{("Option 2")}}</span> <p><p> <p><p> <form action="/sign" method="post"> <div><textarea name="content" rows="3" cols="60"></textarea></div> <div><input type="submit" value="Sign Guestbook"></div> </form> <a href="{{ url }}">{{ url_linktext }}</a> <br> <br> <br> </body> </html> and helloword.py: import urllib import webapp2 from google.appengine.ext import db from google.appengine.api import users import jinja2 import os jinja_environment = jinja2.Environment( loader=jinja2.FileSystemLoader(os.path.dirname(__file__))) class Greeting(db.Model): """Models an individual Guestbook entry with an author, content, and date.""" opts=db.StringListProperty() author = db.StringProperty() content = db.StringProperty(multiline=True, indexed=False) date = db.DateTimeProperty(auto_now_add=True) def _GuestbookKey(guestbook_name=None): """Constructs a Datastore key for a Guestbook entity with guestbook_name.""" return db.Key.from_path('Guestbook', guestbook_name or 'default_guestbook' ) class MainPage(webapp2.RequestHandler): def get(self): # pylint:disable-msg=invalid-name """Handle GET requests.""" guestbook_name = self.request.get('guestbook_name') greetings_query = Greeting.all().ancestor( _GuestbookKey(guestbook_name)).order('-date') greetings = greetings_query.fetch(10) if users.get_current_user(): url = users.create_logout_url(self.request.uri) url_linktext = 'Logout' else: url = users.create_login_url(self.request.uri) url_linktext = 'Login' ## opt=self.request.get('opts',[]) template_values = { 'greetings': greetings, 'url': url, 'url_linktext': url_linktext, } ## 'opts': dict.fromkeys(opt, 'checked') template = jinja_environment.get_template('index.html') self.response.out.write(template.render(template_values)) class Guestbook(webapp2.RequestHandler): def post(self): # pylint:disable-msg=invalid-name """Handle POST requests.""" # We set the same parent key on the 'Greeting' to ensure each greeting is in # the same entity group. Queries across the single entity group will be # consistent. However, the write rate to a single entity group should # be limited to ~1/second. guestbook_name = self.request.get('guestbook_name') greeting = Greeting(parent=_GuestbookKey(guestbook_name)) if users.get_current_user(): greeting.author = users.get_current_user().nickname() allopts=['option 1','option 2'] greeting.opts=[op for op in allopts if self.request.get(op)] ## greeting.opts=self.request.get("opts", allow_multiple=True) greeting.content = self.request.get('content') greeting.put() self.redirect('/?' + urllib.urlencode({'guestbook_name': guestbook_name })) APP = webapp2.WSGIApplication([ ('/', MainPage), ('/sign', Guestbook), ], debug=True) -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To post to this group, send email to google-appengine@googlegroups.com. Visit this group at http://groups.google.com/group/google-appengine. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/a8a3f456-cc26-43d4-a911-fd36dd9f2dde%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.