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


Python Book.summary方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import summary [as 别名]
    def post(self):
        book = Book()
        
        book.rating = self.request.get('rating')
        book.title = self.request.get('title')

        book.summary = self.request.get('summary') if self.request.get('summary') != book.summary else book.summary
        book.first = self.request.get('first') if self.request.get('first') != book.first else book.first
        book.second = self.request.get('second') if self.request.get('second') != book.second else book.second
        book.third = self.request.get('third') if self.request.get('third') != book.third else book.third

        book.notes = self.request.get('notes') if self.request.get('notes') != book.notes else book.notes

        if book.amazon_link != db.Link(self.request.get('amazon')):
            book.amazon_link = db.Link(self.request.get('amazon'))

        book.url = (self.request.path).lstrip('/edit')

        book.put()

        self.redirect('/%s' % book.url)
开发者ID:leogau,项目名称:booksapp,代码行数:23,代码来源:book.py

示例2: post

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import summary [as 别名]
    def post(self):
        book = Book()

        book.rating = self.request.get('rating')
        book.title = self.request.get('title')

        book.summary = self.request.get('summary')
        book.first = self.request.get('first')
        book.second = self.request.get('second')
        book.third = self.request.get('third')

        book.notes = self.request.get('notes')
        
        book.amazon_link = db.Link(self.request.get('amazon'))
        book.url = self.request.get('title').replace(' ', '').lower()
       # book.url = string.translate(url,string.maketrans('',''), string.punctuation)

#        cover = self.request.get('img')
        book.cover = self.request.get('img')

        book.put()

        self.redirect('/')
开发者ID:leogau,项目名称:booksapp,代码行数:25,代码来源:admin.py

示例3: edit_book

# 需要导入模块: from models import Book [as 别名]
# 或者: from models.Book import summary [as 别名]
def edit_book(number):
	amazon_img = False
	if number == 'new':
		book = Book()
		book.mass = 0
		book.width = 0
		book.length = 0
		book.thickness = 0
		title = 'Ajouter un livre dans la bibliotheque'
	elif number[0:7] == 'amazon:':
		import urllib
		asin=unicode(number[7:])
		amazon = bottlenose.Amazon(AWS_KEY,AMAZON_SECRET_KEY,LANG)
		#
		# we fetch the primary informations from large group amazon search
		#
		fetch = amazon.ItemLookup(IdType='ASIN', ItemId= asin, ResponseGroup='Large')
		xml = objectify.fromstring(fetch)
		book = Book()
		try:
			book.title = unicode(xml.Items.Item.ItemAttributes.Title)
		except AttributeError:
			book.title = ''
		try:
			amazon_img = unicode(xml.Items.Item.LargeImage.URL)
		except AttributeError:
			amazon_img = ''
		try:
			book.isbn = unicode(xml.Items.Item.ItemAttributes.ISBN)
		except AttributeError:
			book.isbn = ''
		try:
			book.ean = unicode(xml.Items.Item.ItemAttributes.EAN)
		except AttributeError:
			book.ean = ''
		try:
			book.publisher = unicode(xml.Items.Item.ItemAttributes.Publisher)
		except AttributeError:
			book.publisher = ''
		
		#
		# amazon works in US units (hundreds-inches and pounds). I want them in kilos and cm, so I import the data in float and translate.
		#
		try:
			thickness = float(xml.Items.Item.ItemAttributes.PackageDimensions.Height)
			book.thickness = round(thickness * 2.54/100, 1)
		except AttributeError:
			book.thickness = ''
		try:
			length = float(xml.Items.Item.ItemAttributes.PackageDimensions.Length)
			book.length = round(length * 2.54/100, 1)
		except AttributeError:
			book.length = ''
		try:
			width = float(xml.Items.Item.ItemAttributes.PackageDimensions.Width)
			book.width = round(width * 2.54/100, 1)
		except AttributeError:
			book.width = ''
		try:
			mass = float(xml.Items.Item.ItemAttributes.PackageDimensions.Weight)
			book.mass = round(mass * 0.45/100,2)
		except AttributeError:
			book.mass = ''
		try:
			book.numberofpages = int(xml.Items.Item.ItemAttributes.NumberOfPages)
		except AttributeError:
			book.numberofpages = ''
		try:
			book.summary = unicode(xml.Items.Item.EditorialReviews.EditorialReview.Content)
		except AttributeError:
			book.summary = ''
		title = 'Ajouter un livre d\'Amazon dans la bibliotheque'

	else:
		book = Book.query.get(number)
		title = book.title
		if os.path.exists('app/static/covers/' + str(book.id)):
			book.img = True
	form = BookForm()
	form.authortoadd.choices = Author.query.filter(Author!=book.authors)
	update = False
	#if form.validate_on_submit():
	if request.form=='POST' and form.validate():
		#print form.errors
		book.title = unicode(form.title.data)
		# on ajoute les élements en dessous, mais s'ils ne sont pas là, c'est pas grave !
		if form.ean.data != book.ean:
			book.ean = unicode(form.ean.data)
			update = True
		if form.isbn.data != book.isbn:
			book.isbn = unicode(form.isbn.data)
			update = True
		if form.thickness.data != book.thickness:
			book.thickness = unicode(form.thickness.data)
			update = True
		if form.width.data != book.width:
			book.width = unicode(form.width.data)
			update = True
		if form.length.data != book.length:
			book.length = form.length.data
#.........这里部分代码省略.........
开发者ID:22decembre,项目名称:biblib,代码行数:103,代码来源:views.py


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