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


Python LiveUpdateStream.add_update方法代码示例

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


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

示例1: POST_update

# 需要导入模块: from reddit_liveupdate.models import LiveUpdateStream [as 别名]
# 或者: from reddit_liveupdate.models.LiveUpdateStream import add_update [as 别名]
    def POST_update(self, form, jquery, text):
        if form.has_errors("body", errors.NO_TEXT,
                                   errors.TOO_LONG):
            return

        # create and store the new update
        update = LiveUpdate(data={
            "author_id": c.user._id,
            "body": text,
            "_spam": c.user._spam,
        })

        hooks.get_hook("liveupdate.update").call(update=update)

        LiveUpdateStream.add_update(c.liveupdate_event, update)

        # tell the world about our new update
        builder = LiveUpdateBuilder(None)
        wrapped = builder.wrap_items([update])[0]
        rendered = wrapped.render(style="api")
        _broadcast(type="update", payload=rendered)

        # Queue up parsing any embeds
        queue_parse_embeds(c.liveupdate_event, update)

        # reset the submission form
        t = form.find("textarea")
        t.attr('rows', 3).html("").val("")
开发者ID:hubwub,项目名称:reddit-plugin-liveupdate,代码行数:30,代码来源:controllers.py

示例2: parse_embeds

# 需要导入模块: from reddit_liveupdate.models import LiveUpdateStream [as 别名]
# 或者: from reddit_liveupdate.models.LiveUpdateStream import add_update [as 别名]
def parse_embeds(event_id, liveupdate_id, maxwidth=_EMBED_WIDTH):
    """Find, scrape, and store any embeddable URLs in this liveupdate.

    Return the newly altered liveupdate for convenience.
    Note: This should be used in async contexts only.

    """
    if isinstance(liveupdate_id, basestring):
        liveupdate_id = uuid.UUID(liveupdate_id)

    try:
        event = LiveUpdateEvent._byID(
            event_id, read_consistency_level=tdb_cassandra.CL.QUORUM)
        liveupdate = LiveUpdateStream.get_update(
            event, liveupdate_id, read_consistency_level=tdb_cassandra.CL.QUORUM)
    except tdb_cassandra.NotFound:
        g.log.warning("Couldn't find event/liveupdate for embedding: %r / %r",
                      event_id, liveupdate_id)
        return

    urls = _extract_isolated_urls(liveupdate.body)
    liveupdate.media_objects = _scrape_media_objects(urls, maxwidth=maxwidth)
    liveupdate.mobile_objects = _scrape_mobile_media_objects(urls)
    LiveUpdateStream.add_update(event, liveupdate)

    return liveupdate
开发者ID:reddit,项目名称:reddit-plugin-liveupdate,代码行数:28,代码来源:media_embeds.py

示例3: POST_strike_update

# 需要导入模块: from reddit_liveupdate.models import LiveUpdateStream [as 别名]
# 或者: from reddit_liveupdate.models.LiveUpdateStream import add_update [as 别名]
    def POST_strike_update(self, form, jquery, update):
        if form.has_errors("id", errors.NO_THING_ID):
            return

        update.stricken = True
        LiveUpdateStream.add_update(c.liveupdate_event, update)

        send_websocket_broadcast(type="strike", payload=update._fullname)
开发者ID:Web5design,项目名称:reddit-plugin-liveupdate,代码行数:10,代码来源:controllers.py

示例4: POST_strike_update

# 需要导入模块: from reddit_liveupdate.models import LiveUpdateStream [as 别名]
# 或者: from reddit_liveupdate.models.LiveUpdateStream import add_update [as 别名]
    def POST_strike_update(self, form, jquery, update):
        if form.has_errors("id", errors.NO_THING_ID):
            return

        if not (c.liveupdate_permissions.allow("edit") or
                (c.user_is_loggedin and update.author_id == c.user._id)):
            abort(403)

        update.stricken = True
        LiveUpdateStream.add_update(c.liveupdate_event, update)

        _broadcast(type="strike", payload=update._fullname)
开发者ID:hubwub,项目名称:reddit-plugin-liveupdate,代码行数:14,代码来源:controllers.py

示例5: POST_strike_update

# 需要导入模块: from reddit_liveupdate.models import LiveUpdateStream [as 别名]
# 或者: from reddit_liveupdate.models.LiveUpdateStream import add_update [as 别名]
    def POST_strike_update(self, form, jquery, update):
        """Strike (mark incorrect and cross out) the content of an update.

        Requires that specified update must have been authored by the user or
        that you have the `edit` permission for this thread.

        See also: [/api/live/*thread*/update](#POST_api_live_{thread}_update).

        """
        if form.has_errors("id", errors.NO_THING_ID):
            return

        if not (c.liveupdate_permissions.allow("edit") or
                (c.user_is_loggedin and update.author_id == c.user._id)):
            abort(403)

        update.stricken = True
        LiveUpdateStream.add_update(c.liveupdate_event, update)

        _broadcast(type="strike", payload=update._fullname)
开发者ID:Safturento,项目名称:reddit-plugin-liveupdate,代码行数:22,代码来源:controllers.py

示例6: POST_update

# 需要导入模块: from reddit_liveupdate.models import LiveUpdateStream [as 别名]
# 或者: from reddit_liveupdate.models.LiveUpdateStream import add_update [as 别名]
    def POST_update(self, form, jquery, text):
        if form.has_errors("body", errors.NO_TEXT,
                                   errors.TOO_LONG):
            return

        # create and store the new update
        update = LiveUpdate(data={
            "author_id": c.user._id,
            "body": text,
        })
        LiveUpdateStream.add_update(c.liveupdate_event, update)

        # tell the world about our new update
        builder = LiveUpdateBuilder(None)
        wrapped = builder.wrap_items([update])
        rendered = [w.render() for w in wrapped]
        send_websocket_broadcast(type="update", payload=rendered)

        # reset the submission form
        t = form.find("textarea")
        t.attr('rows', 3).html("").val("")
开发者ID:Web5design,项目名称:reddit-plugin-liveupdate,代码行数:23,代码来源:controllers.py

示例7: POST_delete_update

# 需要导入模块: from reddit_liveupdate.models import LiveUpdateStream [as 别名]
# 或者: from reddit_liveupdate.models.LiveUpdateStream import add_update [as 别名]
    def POST_delete_update(self, form, jquery, update):
        """Delete an update from the thread.

        Requires that specified update must have been authored by the user or
        that you have the `edit` permission for this thread.

        See also: [/api/live/*thread*/update](#POST_api_live_{thread}_update).

        """
        if form.has_errors("id", errors.NO_THING_ID):
            return

        if not (c.liveupdate_permissions.allow("edit") or
                (c.user_is_loggedin and update.author_id == c.user._id)):
            abort(403)

        update.deleted = True
        LiveUpdateStream.add_update(c.liveupdate_event, update)
        liveupdate_events.update_event(update, context=c, request=request)

        _broadcast(type="delete", payload=update._fullname)
开发者ID:hoihei,项目名称:reddit-plugin-liveupdate,代码行数:23,代码来源:controllers.py

示例8: POST_update

# 需要导入模块: from reddit_liveupdate.models import LiveUpdateStream [as 别名]
# 或者: from reddit_liveupdate.models.LiveUpdateStream import add_update [as 别名]
    def POST_update(self, form, jquery, text):
        """Post an update to the thread.

        Requires the `update` permission for this thread.

        See also: [/api/live/*thread*/strike_update]
        (#POST_api_live_{thread}_strike_update), and
        [/api/live/*thread*/delete_update]
        (#POST_api_live_{thread}_delete_update).

        """
        if form.has_errors("body", errors.NO_TEXT,
                                   errors.TOO_LONG):
            return

        # create and store the new update
        update = LiveUpdate(data={
            "author_id": c.user._id,
            "body": text,
            "_spam": c.user._spam,
        })

        hooks.get_hook("liveupdate.update").call(update=update)

        LiveUpdateStream.add_update(c.liveupdate_event, update)

        # tell the world about our new update
        builder = LiveUpdateBuilder(None)
        wrapped = builder.wrap_items([update])[0]
        rendered = wrapped.render(style="api")
        _broadcast(type="update", payload=rendered)

        # Queue up parsing any embeds
        queue_parse_embeds(c.liveupdate_event, update)

        liveupdate_events.update_event(update, context=c, request=request)

        # reset the submission form
        t = form.find("textarea")
        t.attr('rows', 3).html("").val("")
开发者ID:hoihei,项目名称:reddit-plugin-liveupdate,代码行数:42,代码来源:controllers.py


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