Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

GAE samplesrc movegit add *

  • Loading branch information...
commit 30c3f881e155786aa329940d422ec082e2482e89 1 parent 27a195f
root authored
View
4 bookmark_add.html
@@ -6,10 +6,12 @@
<body>
<form name="form_new" action="/add/" method="post">
<d1>
- <dt>URL</dt>
+ <dt>Title</dt>
<dd>{{ error }}</dd>
<dd><input type="text" name="title" size="50" value="{{ title }}" /></dd>
+ <dt>URL</dt>
<dd><input type="text" name="url" size="50" value="{{ url }}" /></dd>
+ <dt>Comment</dt>
<dd><textarea name="comment">"{{ comment }}"</textarea></dd>
</d1>
<input type="submit" value="NewOrder" />
View
11 bookmark_edit.html
@@ -4,18 +4,21 @@
<title> GAE bookmark </title>
</head>
<body>
- <form name="form_edit" action = "/edit/{{ bookmark.id }}" method="post">
+ <form name="form_edit" action = "/edit/{{ bookmark.key.id }}/" method="post">
<d1>
- <dt>URL</dt>
+ <dt>Title</dt>
+ <dd>{{ error }}</dd>
<dd><input type="text" name="title" size="50" value="{{ bookmark.title }}" />
</dd>
+ <dt>URL</dt>
<dd><input type="text" name="url" size="50" value="{{ bookmark.url }}" />
</dd>
- <dd><textarea name="comment">"{{ bookmark.comment }}"</textarea></dd>
+ <dt>Comment</dt>
+ <dd><textarea name="comment">{{ bookmark.comment }}</textarea></dd>
</d1>
<input type="submit" value="Update"/>
</form>
- <form name="form_delete" action="/delete/{{ bookmark.id }}" method="post">
+ <form name="form_delete" action="/delete/{{ bookmark.key.id }}/" method="post">
<input type="submit" value="Delete" />
</form>
</body>
View
16 bookmark_list.html
@@ -0,0 +1,16 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <title>GAE Bookmark</title>
+</head>
+<body>
+ <h1>Bookmark list</h1>
+ <u1>
+ {% for bookmark in bookmarks %}
+ <li>Title :{{ bookmark.title }}</li>
+ <li>URL :{{ bookmark.url }}</li>
+ <li>Comment :{{ bookmark.comment }}</li>
+ {% endfor %}
+ </u1>
+</body>
+</html>
View
16 bookmarks_main.py
@@ -26,7 +26,7 @@ def get( self ):
"""
path = os.path.join( os.path.dirname( __file__),
'bookmark_add.html' )
- self.response.out.write( template.render( path, None) )
+ self.response.out.write( template.render( path, "") )
def post( self ):
""" Execute new input method, and move to Edit Screen.
@@ -36,7 +36,7 @@ def post( self ):
bookmark = Bookmark( url=url, title=title )
bookmark.comment = self.request.POST['comment']
bookmark.put()
- self.redirect( "/edit/%d/" % (bookmark.key().id() ) )
+ self.redirect( "/edit/%d/" % bookmark.key().id() )
class ListBookmark( webapp.RequestHandler ):
def get( self ):
@@ -51,25 +51,23 @@ def get( self, bookmark_id ):
""" Print Edit screen.
"""
bookmark = Bookmark.get_by_id( int(bookmark_id) )
- data = {
- 'bookmark': bookmark,
- }
- path = os.path.join( os.path.dirname(__file__), 'book_edit.html' )
+ data = { 'bookmark': bookmark }
+ path = os.path.join( os.path.dirname(__file__), "bookmark_edit.html" )
self.response.out.write( template.render( path, data ) )
def post( self, bookmark_id ):
"""Update data, and move List screen
"""
- bookmark = get_bookmark_by_id( bookmark_id )
+ bookmark = Bookmark.get_by_id( int(bookmark_id) )
bookmark.url = self.request.POST['url']
bookmark.title = self.request.POST['title']
bookmark.comment = self.request.POST['comment']
bookmark.put()
- sef.redirect("/")
+ self.redirect("/")
class DeleteBookmark( webapp.RequestHandler ):
def post( self, bookmark_id ):
- bookmark = Bookmark.get_by_id( bookmark_id )
+ bookmark = Bookmark.get_by_id( int(bookmark_id) )
if bookmark:
bookmark.delete()
self.redirect("/")
Please sign in to comment.
Something went wrong with that request. Please try again.