本文整理汇总了Python中db.Db.count_sightings方法的典型用法代码示例。如果您正苦于以下问题:Python Db.count_sightings方法的具体用法?Python Db.count_sightings怎么用?Python Db.count_sightings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Db
的用法示例。
在下文中一共展示了Db.count_sightings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _need_to_record
# 需要导入模块: from db import Db [as 别名]
# 或者: from db.Db import count_sightings [as 别名]
def _need_to_record(cookie, signature, ip_addr, key):
db = Db()
db.connect()
if cookie:
# okay, we have a cookie; check whether we've seen it with this
# fingerprint before
seen = db.count_sightings(cookie, signature)
write_cookie = cookie
else:
seen = 0 # always count cookieless browsers
# we need to log the HMAC'd IP even if there's no cookie so use a
# dummy
write_cookie = 'no cookie'
# now log the cookie, along with encrypted versions of the IP address
# and a quarter-erased IP address, like the one Google keeps
ip, google_style_ip = get_ip_hmacs(ip_addr, key)
db.record_sighting(
write_cookie, signature, ip, google_style_ip)
return seen == 0