def process_article_submission(handler, article_type): property_hash = restful.get_hash_from_request(handler.request, ['title', 'body', 'format', 'legacy_id', ('published', get_datetime), ('updated', get_datetime), ('tags', get_tags), ('html', get_html, 'body', 'format'), ('permalink', permalink_funcs[article_type], 'title', 'published')]) article = model.Article( permalink = property_hash['permalink'], article_type = article_type, title = property_hash['title'], body = property_hash['body'], html = property_hash['html'], published = property_hash['published'], updated = property_hash['updated'], format = 'html') # We are converting everything to HTML from Drupal # since it can mix formats within articles fill_optional_properties(article, property_hash) article.set_associated_data( {'relevant_links': handler.request.get('relevant_links'), 'amazon_items': handler.request.get('amazon_items')}) article.put() restful.send_successful_response(handler, '/' + article.permalink) view.invalidate_cache()
def delete(self, year, month, perm_stem): permalink = year + '/' + month + '/' + perm_stem logging.debug("Deleting blog entry %s", permalink) article = db.Query(model.Article). \ filter('permalink =', permalink).get() article.delete() view.invalidate_cache() restful.send_successful_response(self, "/")
def process_article_edit(handler, permalink): # For http PUT, the parameters are passed in URIencoded string in body body = handler.request.body params = cgi.parse_qs(body) logging.debug(params) article = db.Query(model.Article).filter('permalink =', permalink).get() if 'title' in params: article.title = params['title'][0] if 'tags' in params: article.tags = get_tags(params['tags'][0]) article.body = params['body'][0] article.html = params['body'][0] article.updated = get_datetime() article.put() restful.send_successful_response(handler, '/' + article.permalink) view.invalidate_cache()
def process_comment_submission(handler, article): if not article: handler.error(404) return # Get and store some pieces of information from parent article. # TODO: See if this overhead can be avoided if not article.num_comments: article.num_comments = 1 else: article.num_comments += 1 article_key = article.put() property_hash = restful.get_hash_from_request(handler.request, ['name', 'email', 'title', 'body', 'thread', ('published', get_datetime)]) # Compute a comment key by hashing name, email, and body. # If these aren't different, don't bother adding comment. comment_key = str( hash((property_hash['name'], property_hash['email'], property_hash['body']))) comment = model.Comment( permalink = comment_key, body = property_hash['body'], article = article_key, thread = property_hash['thread']) fill_optional_properties(comment, property_hash) comment.put() restful.send_successful_response(handler, '/' + comment.permalink) view.invalidate_cache()
def get(self): restful.send_successful_response(self, assist.all(task.Task))
def get(self): restful.send_successful_response(self, "<some_stats/>")
def get(self): restful.send_successful_response(self, assist.all(location.Location))
def delete(self): model = location.Location.get(db.Key(restful.get_model_key(self))) db.delete(model) restful.send_successful_response(self, model.to_xml())
def get(self): restful.send_successful_response(self, assist.all(workunit.Workunit))
def delete(self): model = project.Project.get(db.Key(restful.get_model_key(self))) db.delete(model) restful.send_successful_response(self, model.to_xml())
def post(self): model = project.Project() assist.update_model_from_params(model, self.request.params) restful.send_successful_response(self, model.to_xml())
def get(self): restful.send_successful_response(self, assist.all(project_category.ProjectCategory))
def get(self): restful.send_successful_response(self, assist.all(note.Note))
def get(self): restful.send_successful_response(self, assist.all(address.Address))
def post(self): model = task.Task(key_name = restful.gen_new_key()) assist.update_model_from_params(model, self.request.params) restful.send_successful_response(self, model.to_xml())
def get(self): restful.send_successful_response(self, assist.all(user.User))
def delete(self): restful.send_successful_response(self, "<logout>%s</logout>" % (users.create_logout_url("/"), ))
def put(self): model = project.Project.get(db.Key(restful.get_model_key(self))) assist.update_model_from_params(model, self.request.params) restful.send_successful_response(self, model.to_xml())
def post(self): model = location.Location() assist.update_model_from_params(model, self.request.params) restful.send_successful_response(self, model.to_xml())
def get(self): restful.send_successful_response(self, assist.all(project.Project))
def get(self): restful.send_successful_response(self, assist.all(sprint.Sprint))