本文整理汇总了Python中models.Item.url方法的典型用法代码示例。如果您正苦于以下问题:Python Item.url方法的具体用法?Python Item.url怎么用?Python Item.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Item
的用法示例。
在下文中一共展示了Item.url方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_digest
# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import url [as 别名]
def create_digest(self, item_type, github_items):
"""
builds a DigestData instance filled with the digest
"""
issue_list = list(self.get_issues())
digest = DigestData(item_type)
digest.user = self._user
digest.repo = self._repository_name
for github_item in github_items:
if github_item.state == ItemStates.OPEN:
digest.total_opened += 1
elif github_item.state == ItemStates.CLOSED:
digest.total_closed += 1
digest.total_items += 1
item = Item()
item.url = github_item.html_url
item.label = '{}/{}#{}'.format(self._user, self._repository_name, github_item.number)
item.title = github_item.title
item.state = github_item.state
github_user = github_item.user
display_name = github_user.name or github_user.login
if display_name not in digest.users:
user = User()
user.name = display_name
user.gravatar = github_user.avatar_url
digest.users[display_name] = user
digest.items.setdefault(display_name, []).append(item)
return digest
示例2: commit_item_changes
# 需要导入模块: from models import Item [as 别名]
# 或者: from models.Item import url [as 别名]
def commit_item_changes(self,item=None):
creation=not(item)
if not item: item=Item(parent=self.current_user.key())
item_name=self.request.get('name')
item_price=self.request.get('price')
item_description=rich_text.from_style_runs(self.request.get('description'))
item_picture=self.request.get('picture_512')
errors=[]
if item_name=="": errors.append("The item name must not be blank.")
if item_description=="": errors.append("The item description must not be blank.")
try:
item_price=float(item_price)
except ValueError:
errors.append("The price must be a number.")
if item_price <=0: errors.append("The price must be greater than zero.")
if len(errors):
self.render_template('items/form.html',title="Add an Item",item_picture_data=item_picture,item_picture=("data:image/png;base64,%s"%item_picture if item_picture or creation else item.url(named=False,action="picture")),errors=errors,item_expiry=datetime.now()+Item.EXPIRATION_DELTA,item_name=item_name,item_description=item_description,item_price=item_price)
else:
item.name=item_name
item.price=item_price
item.description=item_description
if item_picture: item.picture=base64.b64decode(item_picture)
item.put()
self.log("item %s"%("created" if creation else "edited"))
self.flash("'%s' was %s!"%(item_name,"created" if creation else "edited"))
self.redirect(self.current_user.url())