本文整理汇总了Python中models.Tag.up方法的典型用法代码示例。如果您正苦于以下问题:Python Tag.up方法的具体用法?Python Tag.up怎么用?Python Tag.up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tag
的用法示例。
在下文中一共展示了Tag.up方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Tag [as 别名]
# 或者: from models.Tag import up [as 别名]
def post(self):
user = User.is_logged(self)
if not user:
self.redirect('/')
key = self.request.get('edit')
tags = [a.lower() for a in self.request.get_all('tags[]')]
user = user
ingredients = self.request.get_all('ingredients[]')
directions = self.request.get_all('directions[]')
tags = tags
name = self.request.get('name')
notes = self.request.get('notes')
prep = self.request.get('prep_time')
cook = self.request.get('cook_time')
level = self.request.get('level')
private = True if self.request.get('private') == "1" else False
slug = helpers.sluglify( name )
thumb = None
tinythumb = None
slug_exists = Koch.all().filter('slug =', slug).fetch(1)
if len ( slug_exists ) == 1:
#alreadyexists
slug = "%s-%s" % (slug, helpers.random_string())
if self.request.get('photo'):
try:
img_data = self.request.POST.get('photo').file.read()
img = images.Image(img_data)
img.im_feeling_lucky()
png_data = img.execute_transforms(images.JPEG)
img.resize(620,420)
thumb = img.execute_transforms(images.JPEG)
thmb = images.Image(img_data)
thmb.im_feeling_lucky()
png_data = thmb.execute_transforms(images.JPEG)
thmb.resize(0, 80)
tinythumb = thmb.execute_transforms(images.JPEG)
except images.BadImageError:
pass
except images.NotImageError:
pass
except images.LargeImageError:
pass
if key:
koch = Koch.get( key )
koch.title = name
else:
koch = Koch(slug=slug, title=name, author=user)
koch.notes = notes
koch.prep_time = prep
koch.cook_time = cook
koch.level = level
koch.private = private
koch.tags = tags
koch.ingredients = ingredients
koch.directions = directions
if thumb is not None:
koch.photo = thumb
koch.thumb = tinythumb
for tag in tags:
Tag.up(tag)
if key:
user.recipes += 1
user.put()
koch.put()
self.redirect('/cook/%s' % (user.nickname))