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


Python Subreddit._create_and_subscribe方法代码示例

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


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

示例1: register

# 需要导入模块: from r2.models.subreddit import Subreddit [as 别名]
# 或者: from r2.models.subreddit.Subreddit import _create_and_subscribe [as 别名]
from r2.models.subreddit import Subreddit

try:
    register('admin', 'swordfish', '')
except AccountExists:
    pass

admin = Account._by_name('admin')
admin.email_validated = True
admin._commit()

try:
    Subreddit._by_name('admin')
except NotFound:
    Subreddit._create_and_subscribe('admin', admin,
                                    { 'title': 'Admin',
                                      'type': 'restricted',
                                      'default_listing': 'new' })

try:
    Subreddit._by_name('main')
except NotFound:
    Subreddit._create_and_subscribe('main', admin,
                                    { 'title': 'EA Forum',
                                      'type': 'restricted',
                                      'default_listing': 'new' })

try:
    Subreddit._by_name('meetups')
except NotFound:
    s = Subreddit._create_and_subscribe('meetups', admin,
                                        { 'title': 'Meetups',
开发者ID:RyanCarey,项目名称:eaforum,代码行数:34,代码来源:bootstrap.py

示例2: register

# 需要导入模块: from r2.models.subreddit import Subreddit [as 别名]
# 或者: from r2.models.subreddit.Subreddit import _create_and_subscribe [as 别名]
from r2.models.subreddit import Subreddit

try:
    register("admin", "swordfish", "", False)
except AccountExists:
    pass

admin = Account._by_name("admin")
admin.email_validated = True
admin._commit()

try:
    Subreddit._by_name("lesswrong")
except NotFound:
    Subreddit._create_and_subscribe(
        "lesswrong", admin, {"title": "Less Wrong", "type": "restricted", "default_listing": "blessed"}
    )

try:
    Subreddit._by_name("discussion")
except NotFound:
    s = Subreddit._create_and_subscribe(
        "discussion", admin, {"title": "Less Wrong Discussion", "type": "public", "default_listing": "new"}
    )
    s.header = "/static/logo-discussion.png"
    s.stylesheet = "/static/discussion.css"
    s.infotext = u"""You're looking at Less Wrong's discussion board. This includes
                     all posts, including those that haven't been promoted to the front
                     page yet. For more information, see [About Less Wrong](/about-less-wrong)."""

    s.posts_per_page_multiplier = 4
开发者ID:brendanlong,项目名称:lesswrong,代码行数:33,代码来源:bootstrap.py

示例3: register

# 需要导入模块: from r2.models.subreddit import Subreddit [as 别名]
# 或者: from r2.models.subreddit.Subreddit import _create_and_subscribe [as 别名]
from r2.models.subreddit import Subreddit

try:
    register('admin', 'swordfish', '')
except AccountExists:
    pass

admin = Account._by_name('admin')
admin.email_validated = True
admin._commit()

try:
    Subreddit._by_name('lesswrong')
except NotFound:
    Subreddit._create_and_subscribe('lesswrong', admin,
                                    { 'title': 'Less Wrong',
                                      'type': 'restricted',
                                      'default_listing': 'blessed' })

try:
    Subreddit._by_name('discussion')
except NotFound:
    s = Subreddit._create_and_subscribe('discussion', admin,
                                        { 'title': 'Less Wrong Discussion',
                                          'type': 'public',
                                          'default_listing': 'new' })
    s.header = "/static/logo-discussion.png"
    s.stylesheet = "/static/discussion.css"
    s.infotext = u"""This part of the site is for the discussion of topics not
                     yet ready or not suitable for normal top-level posts.
                     Votes are only worth \N{PLUS-MINUS SIGN}1 point here. For
                     more information, see [About Less Wrong](/about-less-wrong)."""
开发者ID:KnaveOfAllTrades,项目名称:lesswrong,代码行数:34,代码来源:bootstrap.py


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