当前位置: 首页>>代码示例>>Python>>正文


Python Post.put方法代码示例

本文整理汇总了Python中models.Post.put方法的典型用法代码示例。如果您正苦于以下问题:Python Post.put方法的具体用法?Python Post.put怎么用?Python Post.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Post的用法示例。


在下文中一共展示了Post.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_insert

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
    def post_insert(self, _post):
        try:
            owner = User.get_userById(_post.owner.user_id)
            post_key = ndb.Key('AIESEC','Post')
            user_key = ndb.Key('AIESEC', 'User')
        
            if owner:
            
                key = uploadHandler.uploadImage(_post.image)
                url = get_serving_url(key)
            
                post_ = Post(parent = post_key, title = _post.title,
                            text = _post.text, blob_key = key, blob_url = url,
                            owner = User(parent = user_key,user_id = owner[0].user_id, 
                                         email = owner[0].email, user = owner[0].user,
                                         university = owner[0].university, state = owner[0].state))

                post_.put()
                Post.list_(True)
                entityKey = str(post_.key.id())
                _post.eID = entityKey
                return _post
            else:
                raise endpoints.InternalServerErrorException()
        except:
            raise endpoints.InternalServerErrorException()
开发者ID:jreyesdl,项目名称:AIESEC_API,代码行数:28,代码来源:main.py

示例2: get

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
 def get(self):
     post = Post(
         title=self.request.get('title'),
         content=self.request.get('content'),
         place=self.request.get('place')
     )
     post.put()
开发者ID:crumpledpaper,项目名称:singgest,代码行数:9,代码来源:main.py

示例3: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
 def post(self):
     post = Post(
         title=self.request.get('title'),
         content=self.request.get('content')
     )
     post.put()
     self.redirect('/')
开发者ID:JLtheking,项目名称:singgest,代码行数:9,代码来源:main.py

示例4: _record_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
 def _record_post(self, bin, use_get=False):
     post = Post(bin=bin, remote_addr=self.request.remote_addr)
     post.headers        = dict(self.request.headers)
     try:
         post.body           = self.request.body
     except UnicodeDecodeError:
         #post.body_binary    = self.request.body
         pass
     post.query_string   = self.request.query_string
     post.form_data = []
     data_source = self.request.GET if use_get else self.request.POST
     post.size = len(post.body) if post.body else 0
     for k,v in data_source.items():
         if isinstance(v, FieldStorage):
             file_body = v.file.read()
             post.form_data.append([k, {
                 'file_name': v.filename,
                 'file_extension': v.filename.split('.')[-1],
                 'file_digest': hashlib.md5(file_body).hexdigest(),
                 'file_size': round(len(file_body) / 1024.0, 1),
             }])
             post.size += len(file_body)
         else:
             post.form_data.append([k,v])
     post.put()
开发者ID:bholtsclaw,项目名称:postbin,代码行数:27,代码来源:bin.py

示例5: tnx

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
 def tnx():
     entity = Post.get_by_key_name(key_name)
     if entity is None:
         entity = Post(key_name=key_name, **kwds)
         entity.put()
         return (True, entity)
     return (False, entity)
开发者ID:4416,项目名称:hazel-cms,代码行数:9,代码来源:views.py

示例6: sign

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
def sign(request):
    form = PostForm(request.POST)
    if form.is_valid():
        post = Post(author=form.cleaned_data["author"], message=form.cleaned_data["message"])
        post.put()

    return HttpResponseRedirect("/")
开发者ID:donilan,项目名称:study,代码行数:9,代码来源:views.py

示例7: populate

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
    def populate(self):
        data = yaml.load(open('example/data.yaml'))

        blog = Blog.get_or_insert(data['blog']['name'], name=data['blog']['name'])
        for post in data['blog']['posts']:
            post = Post(blog=blog.key, **post)
            post.put()

        return self.redirect_to('index')
开发者ID:ozburo,项目名称:babushka,代码行数:11,代码来源:handlers.py

示例8: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
 def post(self):
     p = Post()
     p.author = users.get_current_user()
     p.content = self.request.get('content')
     p.title = self.request.get('title')
     if self.request.get('is_published', None):
         p.is_published = True
     p.put()
     self.redirect('/admin/blog')
开发者ID:mdwrigh2,项目名称:cthaeh,代码行数:11,代码来源:admin_blog.py

示例9: add_entry

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
def add_entry():
    if not session.get("logged_in"):
        abort(401)

    user = users.get_current_user()
    post = Post(email=user.email(), title=request.form["title"], content=request.form["text"])
    post.put()
    flash("New entry was successfully posted")
    return redirect(url_for("show_entries"))
开发者ID:rbastian,项目名称:gae-flaskr-gauth,代码行数:11,代码来源:views.py

示例10: fetch_threads

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
def fetch_threads(page, next_url=None):
  api = FacebookAPI(page.access_token)
  data = api.fetch_raw(next_url) if next_url else api.fetch(page.key.id() + '/threads')
  docs = []

  if data.get('paging', {}).get('next'):
    taskqueue.Queue('facebook').add(
      taskqueue.Task(
        url='/worker/fetch_page_threads',
        params={
          'key': page.key.urlsafe(),
          'next_url': data.get('paging').get('next'),
        }
      )
    )

  for thread in data.get('data'):
    messages = thread.get('messages').get('data')

    if len(messages) == 0:
      continue

    # Let the first message be the 'post'.
    message = messages.pop()

    post_model = Post(
      parent=page.key,
      is_private=True,
      is_reply=False,
      id=message.get('id'),
      created_time=FacebookAPI.parse_date(message.get('created_time')),
      from_id=message.get('from').get('id'),
      from_name=message.get('from').get('name'),
      message=message.get('message'),
      author=scan_for_author(message.get('message')),
    )
    post_model.put()
    docs.append(search.create_document(post_model))

    # Let the rest of the messages be replies:
    for reply in messages:
      reply_model = Post(
        parent=post_model.key,
        is_private=True,
        is_reply=True,
        id=reply.get('id'),
        created_time=FacebookAPI.parse_date(reply.get('created_time')),
        from_id=reply.get('from').get('id'),
        from_name=reply.get('from').get('name'),
        message=reply.get('message'),
        author=scan_for_author(reply.get('message')),
      )
      reply_model.put()
      docs.append(search.create_document(reply_model))

  search.index(page, docs)
开发者ID:studyindenmark,项目名称:clerkster,代码行数:58,代码来源:worker.py

示例11: sign

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
def sign(request):
  form = GuestbookForm(request.POST)
  if form.is_valid():
    post = Post(message=form.clean_data['message'])
    if users.GetCurrentUser():
      post.author = users.GetCurrentUser()
  
    post.put()

  return HttpResponseRedirect('/')
开发者ID:liseryang,项目名称:openbotlist,代码行数:12,代码来源:views.py

示例12: post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
 def post(self):
     post = Post()
     post.author = User.get_by_id(self.session['user'].email)
     assert author
     post.commit = self.request.get('commit')
     post.image = self.get_uploads('image')[0].key()
     post.share = bool(self.get('share', False))
     post.put()
     
     self.JsonResponse({"STATUS": "SUCCESS"})
开发者ID:georgefs,项目名称:ezselector,代码行数:12,代码来源:views.py

示例13: submit_entry

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
def submit_entry():
	heekPost = PostRoot(key_name='heek', version=2)

	post = Post(parent=heekPost)
	post.text = request.form['message'][0:128]
	post.datetime = datetime.now()

	post.put()

	return redirect(url_for('index'))
开发者ID:jangjunha,项目名称:heek-satcounter,代码行数:12,代码来源:main.py

示例14: new_post

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
def new_post():
    form = PostForm()
    if form.validate_on_submit():
        post = Post(title = form.title.data,
                    content = form.content.data,
                    author = users.get_current_user())
        post.put()
        flash('Post saved on database.')
        return redirect(url_for('list_posts'))
    return render_template('new_post.html', form=form)
开发者ID:kaptux,项目名称:gaeseries,代码行数:12,代码来源:views.py

示例15: add_entry

# 需要导入模块: from models import Post [as 别名]
# 或者: from models.Post import put [as 别名]
def add_entry():
    if not session.get('logged_in'):
        abort(401)
#    g.db.execute('insert into entries (title, text) values (?, ?)',
#        [request.form['title'], request.form['text']])
#    g.db.commit()

    post = Post(title=request.form['title'], content=request.form['text'])
    post.put()
    flash('New entry was successfully posted')
    return redirect(url_for('show_entries'))
开发者ID:rbastian,项目名称:gae-flaskr,代码行数:13,代码来源:views.py


注:本文中的models.Post.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。