本文整理汇总了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()
示例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()
示例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('/')
示例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()
示例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)
示例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("/")
示例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')
示例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')
示例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"))
示例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)
示例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('/')
示例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"})
示例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'))
示例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)
示例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'))