Пример #1
0
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()
Пример #2
0
 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, "/")
Пример #3
0
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()
Пример #4
0
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()
Пример #5
0
 def get(self):
   restful.send_successful_response(self, assist.all(task.Task))
Пример #6
0
 def get(self):
   restful.send_successful_response(self, "<some_stats/>")
Пример #7
0
 def get(self):
   restful.send_successful_response(self, assist.all(location.Location))
Пример #8
0
 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())
Пример #9
0
 def get(self):
   restful.send_successful_response(self, assist.all(workunit.Workunit))
Пример #10
0
 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())
Пример #11
0
 def post(self):
   model = project.Project()
   assist.update_model_from_params(model, self.request.params)
   restful.send_successful_response(self, model.to_xml())
Пример #12
0
 def get(self):
   restful.send_successful_response(self, assist.all(project_category.ProjectCategory))
Пример #13
0
 def get(self):
   restful.send_successful_response(self, assist.all(note.Note))
Пример #14
0
 def get(self):
   restful.send_successful_response(self, assist.all(address.Address))
Пример #15
0
 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())
Пример #16
0
 def get(self):
   restful.send_successful_response(self, assist.all(user.User))
Пример #17
0
 def delete(self):
   restful.send_successful_response(self, "<logout>%s</logout>" % (users.create_logout_url("/"), ))
Пример #18
0
 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())
Пример #19
0
 def post(self):
   model = location.Location()
   assist.update_model_from_params(model, self.request.params)
   restful.send_successful_response(self, model.to_xml())
Пример #20
0
 def get(self):
   restful.send_successful_response(self, assist.all(project.Project))
Пример #21
0
 def get(self):
   restful.send_successful_response(self, assist.all(sprint.Sprint))