本文整理匯總了Python中models.Customer.create方法的典型用法代碼示例。如果您正苦於以下問題:Python Customer.create方法的具體用法?Python Customer.create怎麽用?Python Customer.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Customer
的用法示例。
在下文中一共展示了Customer.create方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_user_creation_and_editing
# 需要導入模塊: from models import Customer [as 別名]
# 或者: from models.Customer import create [as 別名]
def test_user_creation_and_editing(self):
test_user = users.User('[email protected]')
new = Customer.create(url='test', user=test_user)
self.assertTrue(new)
self.assertEqual(Customer.get_points_for('test').__len__(), 0)
self.assertTrue(Point.create_point(new, dict(lat=63.345, lon= -4.23)))
self.assertEqual(Customer.get_points_for('test').__len__(), 1)
self.assertRaises(Exception, Customer.create, url='test', user=users.User('[email protected]'))
self.assertRaises(Exception, Customer.create, url='TeSt', user=users.User('[email protected]'))
self.assertRaises(Exception, Customer.create, url='new_test', user=test_user)
renew = Customer.create(url='newtest', user=test_user)
self.assertTrue(renew)
self.assertEqual(Customer.get_points_for('newtest').__len__(), 1)
self.assertTrue(Point.create_point(renew, dict(lat=43.345, lon= -3.23)))
self.assertEqual(Customer.get_points_for('newtest').__len__(), 2)
示例2: create_customer
# 需要導入模塊: from models import Customer [as 別名]
# 或者: from models.Customer import create [as 別名]
def create_customer(url, user):
return Customer.create(url, user)
示例3: BeautifulSoup
# 需要導入模塊: from models import Customer [as 別名]
# 或者: from models.Customer import create [as 別名]
page = requests.get(url)
print "2"
bf = BeautifulSoup(page.content)
print "3"
review_list = bf.find_all('div',{'class','criticinfo'})
#print "getting " + len(review_list) + " customer info"
for review in review_list:
info = review.find('a')
customer_name = info.text
customer_href = info.get('href')
print "try to save customer " + customer_name
try:
customer = Customer.create(
name = customer_name,
href = customer_href,
fetched = False)
customer.save()
print "customer saved"
customer_movie = Customer_Movie.create(
customer = customer,
movie = movie)
customer_movie.save()
print "customer_movie saved"
except Exception, e:
print "exception when saving customer"
movie.fetched = True;
movie.save()