本文整理汇总了Python中r2.models.account.Account._by_name方法的典型用法代码示例。如果您正苦于以下问题:Python Account._by_name方法的具体用法?Python Account._by_name怎么用?Python Account._by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类r2.models.account.Account
的用法示例。
在下文中一共展示了Account._by_name方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_author_name
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _by_name [as 别名]
def get_author_name(author_name):
if not author_name:
return "[unknown]"
try:
return Account._by_name(author_name).name
except NotFound:
return "[deleted]"
示例2: _copy_multi
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _by_name [as 别名]
def _copy_multi(self, from_multi, to_path_info):
self._check_new_multi_path(to_path_info)
to_owner = Account._by_name(to_path_info["username"])
try:
LabeledMulti._byID(to_path_info["path"])
except tdb_cassandra.NotFound:
to_multi = LabeledMulti.copy(to_path_info["path"], from_multi, owner=to_owner)
else:
raise RedditError("MULTI_EXISTS", code=409, fields="multipath")
return to_multi
示例3: register
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _by_name [as 别名]
# Initialise a newly-created db with required tables, users,
# categories and tags.
from r2.lib.db.thing import NotFound
from r2.models.account import Account, AccountExists, register
from r2.models.link import Tag, TagExists
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"
示例4: register
# 需要导入模块: from r2.models.account import Account [as 别名]
# 或者: from r2.models.account.Account import _by_name [as 别名]
# Initialise a newly-created db with required tables, users,
# categories and tags.
from r2.lib.db.thing import NotFound
from r2.models.account import Account, AccountExists, register
from r2.models.link import Tag, TagExists
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' })