本文整理汇总了Python中models.Subscription.get_active_subscriptions方法的典型用法代码示例。如果您正苦于以下问题:Python Subscription.get_active_subscriptions方法的具体用法?Python Subscription.get_active_subscriptions怎么用?Python Subscription.get_active_subscriptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Subscription
的用法示例。
在下文中一共展示了Subscription.get_active_subscriptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get_active_subscriptions [as 别名]
def post(self):
active_subs = Subscription.get_active_subscriptions()
items = json.loads(self.request.get('items'))
logging.debug('before parsing, memory: %s' % runtime.memory_usage().current())
parser = RentParser()
parsed_items = []
for item in items:
try:
parsed = parser.parse(item)
ret = RentRecord.add_record(parsed)
except Exception as e:
logging.error(repr(e))
parsed_items.append(parsed)
logging.debug('after parsing, memory: %s' % runtime.memory_usage().current())
user2message = filter_items(parsed_items, active_subs)
for user, item in user2message.items():
logging.debug('user: %s has %d messages' % (user, len(item)))
User.update_user_items(user, item)
url = get_short_url(user)
if not url:
url = site_config.url + '?user=%s' % user
msg = [u'新找到%d条租房信息。' % len(item),
u'点击以下链接查看:',
url]
messenger.send_message(user, '\n'.join(msg))
示例2: testAddSubscription
# 需要导入模块: from models import Subscription [as 别名]
# 或者: from models.Subscription import get_active_subscriptions [as 别名]
def testAddSubscription(self):
Subscription.add_subscription('user1', 'kw1')
Subscription.add_subscription('user2', 'kw2')
Subscription.add_subscription('user1', 'kw2')
Subscription.add_subscription('user2', 'kw2')
ret = Subscription.get_active_subscriptions()
print ret
self.assertEqual(3, len(ret))