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


Python Account._by_name方法代码示例

本文整理汇总了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]"
开发者ID:nandhinijie,项目名称:reddit,代码行数:9,代码来源:wiki.py

示例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
开发者ID:JBTech,项目名称:reddit,代码行数:15,代码来源:multi.py

示例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"
开发者ID:brendanlong,项目名称:lesswrong,代码行数:33,代码来源:bootstrap.py

示例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' })
开发者ID:RyanCarey,项目名称:eaforum,代码行数:33,代码来源:bootstrap.py


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