当前位置: 首页>>代码示例>>Python>>正文


Python Feed.put方法代码示例

本文整理汇总了Python中models.Feed.put方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.put方法的具体用法?Python Feed.put怎么用?Python Feed.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Feed的用法示例。


在下文中一共展示了Feed.put方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_with_permanent_redirect

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
    def test_get_with_permanent_redirect(self):
        # Create a dummy feed with a last_checked date well in the past
        last_checked = datetime(2013, 9, 21, 10, 0, 0, 0)
        date_of_last_entry = datetime(2013, 9, 20, 8, 45, 0, 0)
        feed = Feed(name = "Test Feed1",
                    last_checked = last_checked,
                    date_of_last_entry = date_of_last_entry,
                    url = './test-feeds/test-rss.xml',
                    parent = root_key())
        feed.put()

        # Stub out the publish_entry function so we don't have to deal with
        # the GAE mail API
        def _publish_entry(feed_title, entry, recipent_address):
            pass
        feed_utils.publish_entry = _publish_entry

        # Create a dummy function to return the feeds to check
        def _find_feeds_to_check(working_date = datetime.now()):
            return [feed]
        feed_utils.find_feeds_to_check = _find_feeds_to_check

        # Replace feedparser.parse with our own version that sets the status
        # code to 301 and the href to a new URL
        def _parse(url):
            parsed_feed = self.orig_parse_func(url)
            parsed_feed['status'] = 301
            parsed_feed['href'] = 'http://def.com'
            return parsed_feed
        feedparser.parse = _parse

        response = self.testapp.get('/check_feeds')

        # check the feed's URL has been updated
        self.assertEquals(feed.url, 'http://def.com')
开发者ID:adrian,项目名称:feed2me,代码行数:37,代码来源:test_check_feeds_handler.py

示例2: testFindFeedsToCheckMoreHoursThanFeeds

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
    def testFindFeedsToCheckMoreHoursThanFeeds(self):
        feeds = [
            {
                'name': 'Test 1',
                'last_checked': datetime(2017, 5, 6, 19, 7, 33)
            },
            {
                'name': 'Test 2',
                'last_checked': datetime(2017, 5, 5, 19, 6, 9)
            },
            {
                'name': 'Test 3',
                'last_checked': datetime(2017, 5, 4, 18, 23, 56)
            }
        ]

        for feed_data in feeds:
            feed = Feed(name = feed_data['name'],
                        last_checked = feed_data['last_checked'],
                        parent = root_key())
            feed.put()

        working_date = datetime(2017, 5, 6, 19, 45, 0)
        feeds = feed_utils.find_feeds_to_check(working_date)

        # there are 4 hours left in the day so only 1 feed will be returned
        self.assertEqual(1, len(feeds))
        self.assertEqual("Test 3", feeds[0].name)
开发者ID:adrian,项目名称:feed2me,代码行数:30,代码来源:test_feed_utils.py

示例3: create_feed

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
def create_feed(user,board_id,title,link,description,actions,public_board,get_all,token):
    """ Creates a feed and attaches it to a user object """
    user = get_user(user)
    q = Feed.query(
        Feed.channel_title==title,
        Feed.channel_link==link,
        Feed.channel_description==description,
        Feed.feed_name==title,
        Feed.token==token,
        Feed.actions.IN(actions),
        Feed.board_id==board_id,
        Feed.public_board==public_board)
    feed = q.get()
    if feed is None:
        feed = Feed(
            channel_title=title,
            channel_link=link,
            channel_description=description,
            feed_name=title,
            token=token,
            actions=actions,
            board_id=board_id,
            public_board=public_board,
            get_all=get_all,user=user.key)
        feed.put()
    if user.feeds:
        if feed.key not in user.feeds:
            user.feeds.append(feed.key)
            user.put()
    else:
        user.feeds = [feed.key]
        user.put()
    return create_url(feed.key.id())
开发者ID:naiyt,项目名称:trellorss-gae,代码行数:35,代码来源:utils.py

示例4: post

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
    def post(self):
        #表单字段: url, author, title, content, allow_sendto_kindle
        f = Feed()
        f.url = self.request.get('tUrl')
        f.title = self.request.get('tTitle')
        f.put(); # save

        return self.redirect('/feed')
开发者ID:tonychi,项目名称:readLater,代码行数:10,代码来源:main.py

示例5: add_feed

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
def add_feed():
    title = request.form.get('title')
    url = request.form.get('url')
    delay = request.form.get('delay')
    feed = Feed()
    feed.url = url
    feed.title = title
    feed.delay = delay
    feed.latest_fetch = datetime.datetime.now()
    feed.put()
    flash(u'KeyWord add successfully~', 'success')
    flush_feed_cache()
    return redirect(url_for("admin"))
开发者ID:abazad,项目名称:RSSNewsGAE,代码行数:15,代码来源:admin.py

示例6: test_check_feed_with_probem

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
    def test_check_feed_with_probem(self):
        last_checked = datetime(2000, 1, 1)
        date_of_last_entry = datetime(2000, 1, 1)
        feed_url = 'http://x.y.z'
        feed = Feed(name = "Test Feed",
                    last_checked = last_checked,
                    date_of_last_entry = date_of_last_entry,
                    url = feed_url,
                    parent = root_key())
        feed.put()

        # Replace feedparser.parse with our own version that sets the status
        # code to 500 to simulate a server side error
        def _parse(url):
            parsed_feed = FeedParserDict(status = 500, bozo = False)
            return parsed_feed
        feedparser.parse = _parse

        reported_title = [0]
        reported_message = [0]
        reported_recipient = [0]
        orig_report_error = feed_utils.report_error
        def _report_error(title, message, recipent_address):
            reported_title[0] = title
            reported_message[0] = message
            reported_recipient[0] = recipent_address
            orig_report_error(title, message, recipent_address)
        feed_utils.report_error = _report_error

        # run the method under test
        # set logging to CRITICAL so-as not to print exception generated by
        # the test
        try:
            logging.getLogger().setLevel(logging.CRITICAL)
            response = self.testapp.get('/check_feeds')
            self.assertEquals(reported_title[0], feed.name)
            self.assertTrue('returned HTTP code 500' in reported_message[0])
            self.assertEquals(reported_recipient[0], '[email protected]')
            #self.fail("Should have raised an exception as server returned 500")
        finally:
            logging.getLogger().setLevel(logging.ERROR)

        # there should be one email message describing the problem
        messages = self.mail_stub.get_sent_messages()
        self.assertEquals(1, len(messages))
        self.assertTrue("URL '%s' returned HTTP code 500" % feed_url in
            messages[0].body.payload)

        # check the feed's last_checked date was updated
        self.assertNotEqual(feed.last_checked, last_checked)
开发者ID:adrian,项目名称:feed2me,代码行数:52,代码来源:test_check_feeds_handler.py

示例7: testFindFeedsToCheckNoHoursLeftInDay

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
    def testFindFeedsToCheckNoHoursLeftInDay(self):
        feeds = [
            {
                'name': 'Test 1',
                'last_checked': datetime(2017, 5, 6, 19, 7, 33)
            }
        ]

        for feed_data in feeds:
            feed = Feed(name = feed_data['name'],
                        last_checked = feed_data['last_checked'],
                        parent = root_key())
            feed.put()

        working_date = datetime.now().replace(hour=23, minute=59, second=59)
        feeds = feed_utils.find_feeds_to_check(working_date)
        self.assertEqual(1, len(feeds))
        self.assertEqual("Test 1", feeds[0].name)
开发者ID:adrian,项目名称:feed2me,代码行数:20,代码来源:test_feed_utils.py

示例8: test_get

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
    def test_get(self):
        # Create a dummy feed with a last_checked date well in the past
        last_checked = datetime(2013, 9, 21, 10, 0, 0, 0)
        date_of_last_entry = datetime(2013, 9, 20, 8, 45, 0, 0)
        feed = Feed(name = "Test Feed1",
                    last_checked = last_checked,
                    date_of_last_entry = date_of_last_entry,
                    url = './test-feeds/test-rss.xml',
                    parent = root_key())
        feed.put()

        # Create a dummy function to capture calls to publish_entry
        publish_entry_called = [False]
        def _publish_entry(feed_title, entry, recipent_address):
            publish_entry_called[0] = True
        feed_utils.publish_entry = _publish_entry

        # Create a dummy function to return the feeds to check
        def _find_feeds_to_check(working_date = datetime.now()):
            return [feed]
        feed_utils.find_feeds_to_check = _find_feeds_to_check

        # Replace feedparser.parse with our own version that sets the status
        # code to 200 and the href to a new URL
        def _parse(url):
            parsed_feed = self.orig_parse_func(url)
            parsed_feed['status'] = 200
            return parsed_feed
        feedparser.parse = _parse

        # call the method under test
        response = self.testapp.get('/check_feeds')

        # check the publish_entry method was called
        self.assertTrue(publish_entry_called[0],
            "publish_entry function not called")

        # check the feed's last_checked date was updated
        self.assertNotEquals(feed.last_checked, last_checked,
            "last_checked not updated")
开发者ID:adrian,项目名称:feed2me,代码行数:42,代码来源:test_check_feeds_handler.py

示例9: testFindFeedsToCheckThreeHoursSixFeeds

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
    def testFindFeedsToCheckThreeHoursSixFeeds(self):
        feeds = [
            {
                'name': 'Test 1',
                'last_checked': datetime(2017, 5, 6, 19, 7, 33)
            },
            {
                'name': 'Test 2',
                'last_checked': datetime(2017, 5, 5, 19, 6, 9)
            },
            {
                'name': 'Test 3',
                'last_checked': datetime(2017, 5, 2, 18, 23, 56)
            },
            {
                'name': 'Test 4',
                'last_checked': datetime(2017, 5, 3, 18, 23, 56)
            },
            {
                'name': 'Test 5',
                'last_checked': datetime(2017, 5, 1, 18, 23, 56)
            },
            {
                'name': 'Test 6',
                'last_checked': datetime(2017, 5, 4, 18, 23, 56)
            }
        ]

        for feed_data in feeds:
            feed = Feed(name = feed_data['name'],
                        last_checked = feed_data['last_checked'],
                        parent = root_key())
            feed.put()

        working_date = datetime(2017, 5, 7, 20, 45, 0)
        feeds = feed_utils.find_feeds_to_check(working_date)
        self.assertEqual(2, len(feeds))
        self.assertEqual("Test 5", feeds[0].name)
        self.assertEqual("Test 3", feeds[1].name)
开发者ID:adrian,项目名称:feed2me,代码行数:41,代码来源:test_feed_utils.py

示例10: init_gae

# 需要导入模块: from models import Feed [as 别名]
# 或者: from models.Feed import put [as 别名]
 def init_gae():
     f = Feed()
     f.url = 'http://money.163.com/special/00252EQ2/yaowenrss.xml'
     f.title = '要闻综合-网易财经'
     f.put()
开发者ID:lichenxi,项目名称:StockNewsGAE,代码行数:7,代码来源:controller.py


注:本文中的models.Feed.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。