本文整理汇总了Python中r2.lib.emailer.queue_promo函数的典型用法代码示例。如果您正苦于以下问题:Python queue_promo函数的具体用法?Python queue_promo怎么用?Python queue_promo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了queue_promo函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: charge_pending
def charge_pending(offset=1):
for l, camp, weight in accepted_campaigns(offset=offset):
user = Account._byID(l.author_id)
try:
if charged_or_not_needed(camp):
continue
charge_succeeded = authorize.charge_transaction(user, camp.trans_id,
camp._id)
if not charge_succeeded:
continue
hooks.get_hook('promote.new_charge').call(link=l, campaign=camp)
if is_promoted(l):
emailer.queue_promo(l, camp.bid, camp.trans_id)
else:
set_promote_status(l, PROMOTE_STATUS.pending)
emailer.queue_promo(l, camp.bid, camp.trans_id)
text = ('auth charge for campaign %s, trans_id: %d' %
(camp._id, camp.trans_id))
PromotionLog.add(l, text)
except:
print "Error on %s, campaign %s" % (l, camp._id)
开发者ID:AD42,项目名称:reddit,代码行数:25,代码来源:promote.py
示例2: charge_campaign
def charge_campaign(link, campaign):
if charged_or_not_needed(campaign):
return
user = Account._byID(link.author_id)
success, reason = authorize.charge_transaction(user, campaign.trans_id,
campaign._id)
if not success:
if reason == authorize.TRANSACTION_NOT_FOUND:
# authorization hold has expired
original_trans_id = campaign.trans_id
campaign.trans_id = NO_TRANSACTION
campaign._commit()
text = ('voided expired transaction for %s: (trans_id: %d)'
% (campaign, original_trans_id))
PromotionLog.add(link, text)
return
hooks.get_hook('promote.edit_campaign').call(link=link, campaign=campaign)
if not is_promoted(link):
update_promote_status(link, PROMOTE_STATUS.pending)
emailer.queue_promo(link, campaign.bid, campaign.trans_id)
text = ('auth charge for campaign %s, trans_id: %d' %
(campaign._id, campaign.trans_id))
PromotionLog.add(link, text)
开发者ID:APerson241,项目名称:reddit,代码行数:28,代码来源:promote.py
示例3: _charge
def _charge(l, camp, indx, weight):
user = Account._byID(l.author_id)
sd, ed, bid, sr, trans_id = camp
try:
if (not authorize.is_charged_transaction(trans_id, indx) and
authorize.charge_transaction(user, trans_id, indx)):
# update the query queue
if is_promoted(l):
emailer.queue_promo(l, bid, trans_id)
else:
set_status(l, STATUS.pending,
onchange = lambda: emailer.queue_promo(l, bid, trans_id) )
promotion_log(l, "auth charge for campaign %s, trans_id: %d" % (indx, trans_id), True)
except:
print "Error on %s, campaign %s" % (l, indx)
开发者ID:DanHoerst,项目名称:reddit,代码行数:15,代码来源:promote.py
示例4: _charge
def _charge(l, camp, indx, weight):
user = Account._byID(l.author_id)
sd, ed, bid, sr, trans_id = camp
try:
if (not authorize.is_charged_transaction(trans_id, indx) and
authorize.charge_transaction(user, trans_id, indx)):
# TODO: probably not absolutely necessary
promotion_log(l, "status update: pending")
# update the query queue
if is_promoted(l):
emailer.queue_promo(l, bid, trans_id)
else:
set_status(l, STATUS.pending,
onchange = lambda: emailer.queue_promo(l, bid, trans_id) )
except:
print "Error on %s, campaign %s" % (l, indx)
开发者ID:JediWatchman,项目名称:reddit,代码行数:16,代码来源:promote.py
示例5: charge_pending
def charge_pending(offset=1):
for l, camp, weight in accepted_campaigns(offset=offset):
user = Account._byID(l.author_id)
try:
if authorize.is_charged_transaction(camp.trans_id, camp._id) or not authorize.charge_transaction(
user, camp.trans_id, camp._id
):
continue
if is_promoted(l):
emailer.queue_promo(l, camp.bid, camp.trans_id)
else:
set_status(l, STATUS.pending, onchange=lambda: emailer.queue_promo(l, camp.bid, camp.trans_id))
promotion_log(l, "auth charge for campaign %s, trans_id: %d" % (camp._id, camp.trans_id), commit=True)
except:
print "Error on %s, campaign %s" % (l, camp._id)
开发者ID:jianbin91,项目名称:reddit,代码行数:16,代码来源:promote.py
示例6: pending_promo
def pending_promo(thing):
"""
For an accepted promotion within the proper time interval, charge
the account of the user and set the new status as pending.
"""
if thing.promote_status == STATUS.accepted and thing.promote_trans_id:
user = Account._byID(thing.author_id)
# TODO: check for charge failures/recharges, etc
if authorize.charge_transaction(user, thing.promote_trans_id):
promotion_log(thing, "status update: pending")
thing.promote_status = STATUS.pending
thing.promote_paid = thing.promote_bid
thing._commit()
emailer.queue_promo(thing)
else:
promotion_log(thing, "status update: charge failure")
thing._commit()
开发者ID:kevinrose,项目名称:diggit,代码行数:17,代码来源:promote.py
示例7: charge_pending
def charge_pending(offset=1):
for l, index, camp in accepted_campaigns(offset=offset):
user = Account._byID(l.author_id)
sd, ed, bid, sr, trans_id = camp
try:
if (authorize.is_charged_transaction(trans_id, index) or not
authorize.charge_transaction(user, trans_id, index)):
continue
if is_promoted(l):
emailer.queue_promo(l, bid, trans_id)
else:
set_status(l, STATUS.pending,
onchange=lambda: emailer.queue_promo(l, bid, trans_id))
promotion_log(l, "auth charge for campaign %s, trans_id: %d" % (index, trans_id), True)
except:
print "Error on %s, campaign %s" % (l, index)
开发者ID:freekrai,项目名称:reddit,代码行数:17,代码来源:promote.py
示例8: charge_pending
def charge_pending(offset=1):
for l, camp, weight in accepted_campaigns(offset=offset):
user = Account._byID(l.author_id)
try:
if (authorize.is_charged_transaction(camp.trans_id, camp._id) or not
authorize.charge_transaction(user, camp.trans_id, camp._id)):
continue
if is_promoted(l):
emailer.queue_promo(l, camp.bid, camp.trans_id)
else:
set_promote_status(l, PROMOTE_STATUS.pending)
emailer.queue_promo(l, camp.bid, camp.trans_id)
text = ('auth charge for campaign %s, trans_id: %d' %
(camp._id, camp.trans_id))
PromotionLog.add(l, text)
except:
print "Error on %s, campaign %s" % (l, camp._id)
开发者ID:vinnydiehl,项目名称:reddit,代码行数:18,代码来源:promote.py
示例9: charge_campaign
def charge_campaign(link, campaign):
if charged_or_not_needed(campaign):
return
user = Account._byID(link.author_id)
charge_succeeded = authorize.charge_transaction(user, campaign.trans_id, campaign._id)
if not charge_succeeded:
return
hooks.get_hook("promote.edit_campaign").call(link=link, campaign=campaign)
if not is_promoted(link):
update_promote_status(link, PROMOTE_STATUS.pending)
emailer.queue_promo(link, campaign.bid, campaign.trans_id)
text = "auth charge for campaign %s, trans_id: %d" % (campaign._id, campaign.trans_id)
PromotionLog.add(link, text)
开发者ID:j2p2,项目名称:reddit,代码行数:18,代码来源:promote.py
示例10: accept_promo
def accept_promo(thing):
"""
Accept promotion and set its status as accepted if not already
charged, else pending.
"""
if thing.promote_status < STATUS.pending:
bid = Bid.one(thing.promote_trans_id)
if bid.status == Bid.STATUS.CHARGE:
thing.promote_status = STATUS.pending
# repromote if already promoted before
if hasattr(thing, "promoted_on"):
promote(thing)
else:
emailer.queue_promo(thing)
else:
thing.promote_status = STATUS.accepted
promotion_log(thing, "status update: accepted")
emailer.accept_promo(thing)
thing._commit()
开发者ID:kevinrose,项目名称:diggit,代码行数:19,代码来源:promote.py
注:本文中的r2.lib.emailer.queue_promo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论