本文整理汇总了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',
示例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
示例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)."""