<s> from django . shortcuts import render_to_response <EOL> from jsonrpc import * <EOL> from gaedjangononrelpuremvcblog . post . models import Post <EOL> service = JSONRPCService ( ) <EOL> def index ( request ) : <EOL> return render_to_response ( '<STR_LIT>' ) <EOL> @ jsonremote ( service ) <EOL> def get_post ( request , num ) : <EOL> post = Post . objects . get ( id = num ) <EOL> return [ ( str ( post . pk ) , str ( post . title ) , str ( post . content ) ) ] <EOL> @ jsonremote ( service ) <EOL> def get_posts ( request ) : <EOL> return [ ( str ( post . pk ) , str ( post . title ) , str ( post . content ) ) for post in Post . objects . all ( ) ] <EOL> @ jsonremote ( service ) <EOL> def update_post ( request , key , title , content ) : <EOL> post = Post . objects . get ( id = key ) <EOL> post = map_remote_post_to_local_post ( title , content , post ) <EOL> post . save ( ) <EOL> return get_post ( request , post . pk ) <EOL> @ jsonremote ( service ) <EOL> def add_post ( request , title , content ) : <EOL> post = Post ( ) <EOL> post = map_remote_post_to_local_post ( title , content , post ) <EOL> post . save ( ) <EOL> return get_post ( request , post . pk ) <EOL> def map_remote_post_to_local_post ( title , content , post ) : <EOL> post . title = title <EOL> post . content = content <EOL> return post <EOL> @ jsonremote ( service ) <EOL> def delete_post ( request , num ) : <EOL> post = Post . objects . get ( id = num ) <EOL> post . delete ( ) <EOL> return num </s>
