本文整理汇总了Python中card.Card.assignPair方法的典型用法代码示例。如果您正苦于以下问题:Python Card.assignPair方法的具体用法?Python Card.assignPair怎么用?Python Card.assignPair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类card.Card
的用法示例。
在下文中一共展示了Card.assignPair方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Card
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import assignPair [as 别名]
# enable debugging
import cgitb
cgitb.enable()
print "Content-Type: text/html;charset=utf-8"
print
connection = pymongo.Connection('localhost', 27017)
db = connection.magic
cards = db.cards
allCards = cards.find()
cardList = []
foundCards = []
for c in allCards:
if c not in foundCards:
card = Card(c)
if c["pair"] is not None:
otherCard = cards.find_one({"_id": c["pair"]})
foundCards.append(otherCard)
card.assignPair(Card(otherCard))
cardList.append(card)
try:
template = Template(filename='modules\\templates\main.html')
print template.render_unicode(cards=cardList).encode('utf-8', 'replace')
except:
print exceptions.text_error_template().render()
示例2: Card
# 需要导入模块: from card import Card [as 别名]
# 或者: from card.Card import assignPair [as 别名]
# -*- coding: UTF-8 -*-
import cgi
from card import Card
from mako.template import Template
from mako import exceptions
import pymongo
print "Content-Type: text/html;charset=utf-8"
print
form = cgi.FieldStorage()
connection = pymongo.Connection('localhost', 27017)
db = connection.magic
cards = db.cards
qs = form.getvalue("card")
if "--" in qs:
c = cards.find_one({"_id": qs.split("--")[0]})
ca = Card(c)
ca.assignPair(Card(cards.find_one({"_id": qs.split("--")[1]})))
else:
c = cards.find_one({"_id": qs})
ca = Card(c)
try:
template = Template(filename='templates\card.html')
print template.render_unicode(card=ca).encode('utf-8', 'replace')
except:
print exceptions.text_error_template().render()