本文整理汇总了Python中blog.models.Entry.get方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.get方法的具体用法?Python Entry.get怎么用?Python Entry.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类blog.models.Entry
的用法示例。
在下文中一共展示了Entry.get方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get [as 别名]
def get(self):
key = self.request.get('key')
item_type = self.request.get('item_type')
if item_type == "entry":
entry = Entry.get(key)
form = EditEntryForm(instance=entry)
else:
entry = Country.get(key)
form = EditCountryForm(instance=entry)
if users.get_current_user():
url = users.create_logout_url(self.request.uri)
url_linktext = 'Logout'
else:
url = users.create_login_url(self.request.uri)
url_linktext = 'Login'
template_values = {
'form': form,
'item_type': item_type,
'key': key,
'url': url,
'url_linktext': url_linktext,
}
path = os.path.join(os.path.dirname(__file__), 'templates/admin/edit.html')
self.response.out.write(template.render(path, template_values))
示例2: POST
# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get [as 别名]
def POST(self,slug=None):
try:
linkcheck= self.request.get_all('checks')
entrykeys=[]
for key in linkcheck:
comment=Comment.get(key)
comment.delit()
entrykeys.append(comment.entry.key())
entrykeys=set(entrykeys)
for key in entrykeys:
e=Entry.get(key)
e.update_commentno()
e.removecache()
memcache.delete("/feed/comments")
finally:
self.redirect(self.request.uri)
示例3: GET
# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get [as 别名]
def GET(self,slug='post'):
action=self.param("action")
entry=None
cats=Category.all()
alltags=Tag.all()
if action and action=='edit':
try:
key=self.param('key')
entry=Entry.get(key)
except:
pass
else:
action='add'
def mapit(cat):
return {'name':cat.name,'slug':cat.slug,'select':entry and cat.key() in entry.categorie_keys}
vals={'action':action,'entry':entry,'entrytype':slug,'cats':map(mapit,cats),'alltags':alltags}
self.render2('views/admin/entry.html',vals)
示例4: action_getcomments
# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get [as 别名]
def action_getcomments(self):
key=self.param('key')
entry=Entry.get(key)
comments=Comment.all().filter(entry = key)
commentuser=self.request.cookies.get('comment_user', '')
if commentuser:
commentuser=commentuser.split('#@#')
else:
commentuser=['','','']
vals={
'entry':entry,
'comments':comments,
'user_name':commentuser[0],
'user_email':commentuser[1],
'user_url':commentuser[2],
'checknum1':random.randint(1,10),
'checknum2':random.randint(1,10),
}
html=self.get_render('comments',vals)
self.write(simplejson.dumps(html.decode('utf8')))
示例5: post
# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get [as 别名]
def post(self):
self.response.out.write('<html><body>You wrote:<pre>')
key = self.request.get('id_key')
title = self.request.get('title')
slug = str(slugify(title))
item_type = self.request.get('item_type')
tag_list = None
if item_type == "entry":
content = self.request.get('content')
genre = self.request.get('genre')
enable_comments = self.request.get('enable_comments')
country = self.request.get('country')
core_topic = self.request.get('core_topic')
tags = self.request.get('tags')
private = self.request.get('private')
publish_date = self.request.get('publish_date')
if publish_date:
publish_date = datetime.strptime(publish_date, '%Y-%m-%d').date()
else:
publish_date = datetime.today().date()
if genre == "blog":
country_obj = Country.get(country)
else:
country_obj = None
if key:
entry = Entry.get(key)
else:
entry = Entry()
entry.title = title
entry.slug = slug
entry.content = content
entry.genre = genre
entry.country = country_obj
entry.publish_date = publish_date
if len(core_topic):
entry.core_topic = core_topic
if private == "on":
b = bool("1")
else:
b = bool("")
entry.private = b
entry.put()
if len(tags) > 0:
tag_list = shlex.split(str(tags))
if tag_list:
for tag in tag_list:
tag_obj = Tag.get_or_insert(str(tag))
if tag_obj.name == None:
tag_obj.name = str(tag)
tag_obj.put()
entry.tags.append(tag_obj.key())
entry.put()
else:
map_url = self.request.get('map_url')
if key:
country = Country.get(key)
else:
country = Country()
country.title = title
country.slug = slug
country.map_url = map_url
country.put()
self.response.out.write(str("Key: %s<br />" % key))
self.response.out.write(str("Title: %s<br />" % title))
self.response.out.write(str("Slug: %s<br />" % slug))
self.response.out.write(str("Type: %s<br />" % item_type))
if tag_list:
self.response.out.write(str("Tags: %s<br />" % tags))
self.response.out.write('</pre></body></html>')
示例6: delete
# 需要导入模块: from blog.models import Entry [as 别名]
# 或者: from blog.models.Entry import get [as 别名]
def delete(self):
key = get_key_from_body(self.request.body)
if key:
instance = Entry.get(db.Key(key))
instance.delete()