當前位置: 首頁>>代碼示例>>Python>>正文


Python User.get_by_name方法代碼示例

本文整理匯總了Python中vilya.models.user.User.get_by_name方法的典型用法代碼示例。如果您正苦於以下問題:Python User.get_by_name方法的具體用法?Python User.get_by_name怎麽用?Python User.get_by_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vilya.models.user.User的用法示例。


在下文中一共展示了User.get_by_name方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_git_path_info

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
def get_git_path_info(path):
    path_split = path.split("/")
    git_name = path_split[1]
    # raw path: project_id.git
    if git_name.endswith('.git'):
        project = Project.get_by_name(git_name[:-4])
        if project:
            path_split[1] = "%s.git" % project.id
            return '/'.join(path_split)
    else:
        owner_name, git_name = path_split[1:3]
        # user project: user/project.git
        user = User.get_by_name(owner_name)
        if user:
            project = Project.get_by_name_and_owner(git_name[:-4], user.id)
            if project:
                path_split[1] = ""
                path_split[2] = "%s.git" % project.id
                return '/'.join(path_split[1:])
            return
        # org project: org/project.git
        org = Organization.get_by_name(owner_name)
        if org:
            project = Project.get_by_name_and_owner(git_name[:-4], user.id)
            if project:
                path_split[1] = ""
                path_split[2] = "%s.git" % project.id
                return '/'.join(path_split[1:])
開發者ID:377262688,項目名稱:code,代碼行數:30,代碼來源:smart_httpd.py

示例2: __token_grant_by_password

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
def __token_grant_by_password(apikey):
    username = __check_request_required_var('username')
    password = __check_request_required_var('password')
    user = User.get_by_name(username)
    if not DEVELOP_MODE and user and not user.validate_password(password):
        raise InvalidRequest(err.username_password_mismatch)

    token = ApiToken.add(apikey.client_id, username)
    return json.dumps(token.token_dict())
開發者ID:000fan000,項目名稱:code,代碼行數:11,代碼來源:oauth.py

示例3: api_list_user

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
def api_list_user(users):
    rs = []
    for username in users:
        user = User.get_by_name(username)
        rs.append({'username': user.username,
                   'avatar_url': user.avatar_url,
                   'email': user.email,
                   'url': user.url, })
    return rs
開發者ID:377262688,項目名稱:code,代碼行數:11,代碼來源:utils.py

示例4: __init__

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
    def __init__(self, repo, commit):
        self.repo = repo
        self._commit = commit
        self.type = 'commit'
        self.repo_name = repo.name
        parent = commit['parent'][0] if commit['parent'] else None
        self.parent = parent
        self.parents = commit['parent']
        message = ("%s\n\n%s" % (
            commit['message'],
            remove_unknown_character(commit['body']))
        ).strip()
        self.message = message
        self.message_header = commit['message']
        self.message_body = commit['body']
        self.sha = commit['sha']
        self.tree = commit['tree']

        author_name = commit['author']['name']
        self.author_name = author_name
        author_email = email_normalizer(author_name, commit['author']['email'])
        self.author_email = author_email
        self.email = author_email
        # FIXME: user
        #author = User(name=author_name, email=author_email)
        author = User.get_by_name(author_name)
        self.author = author
        author_date = datetime.fromtimestamp(commit['author']['time'],
                                             FixedOffset(commit['author']['offset']))
        author_timestamp = str(commit['author']['time'])
        self.author_time = author_date
        self.author_timestamp = author_timestamp
        self.time = author_date

        committer_name = commit['committer']['name']
        committer_email = email_normalizer(
            committer_name, commit['committer']['email'])
        # FIXME: user
        #committer = User(name=committer_name, email=committer_email)
        committer = User.get_by_name(committer_name)
        self.committer = committer
        committer_date = datetime.fromtimestamp(commit['committer']['time'],
                                             FixedOffset(commit['committer']['offset']))
        self.committer_time = committer_date
開發者ID:377262688,項目名稱:code,代碼行數:46,代碼來源:commit.py

示例5: _q_index

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
def _q_index(request):
    if request.method == 'POST':
        name = request.get_form_var('login')
        password = request.get_form_var('password')
        user = User.get_by_name(name)
        if user and user.validate_password(password):
            user.set_session(request)
            request.user = user
            return request.redirect('/')
    return st('login.html')
開發者ID:377262688,項目名稱:code,代碼行數:12,代碼來源:login.py

示例6: __init__

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
 def __init__(self, header):
     self.login = None
     self.passwd = None
     self.user = None
     try:
         auth_type, auth_string = header.split()
         login, passwd = b64decode(auth_string).split(':')
         self.login = login
         self.passwd = passwd
         self.user = User.get_by_name(login)
     except (ValueError, TypeError):
         pass
開發者ID:000fan000,項目名稱:code,代碼行數:14,代碼來源:__init__.py

示例7: _q_lookup

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
def _q_lookup(request, name):
    if name in ['static', 'js', 'css']:
        return StaticUI(request, name)

    user = User.get_by_name(name)
    if user:
        return UserUI(user)

    org = Organization.get_by_name(name)
    if org:
        return OrganizationUI(org)

    raise TraversalError
開發者ID:377262688,項目名稱:code,代碼行數:15,代碼來源:__init__.py

示例8: _q_index

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
def _q_index(request):
    if request.method == 'POST':
        name = request.get_form_var('username')
        password = request.get_form_var('password')
        user = User.get_by_name(name)
        if user and user.validate_password(password):
            continue_url = request.get_form_var(
                'continue', '') or request.get_form_var('Referer', '')
            request.user = user
            set_user(user.id)
            return json.dumps({"r": 0, "continue": continue_url or "/"})
        return json.dumps({"r": 1})
    return st('login.html')
開發者ID:leeccong,項目名稱:code,代碼行數:15,代碼來源:login.py

示例9: _q_lookup

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
    def _q_lookup(self, request, name):
        from vilya.views.api.v1.users import UserUI
        from vilya.views.api.v1.organizations import OrganizationUI

        user = User.get_by_name(name)
        if user:
            return UserUI(user)

        org = Organization.get_by_name(name)
        if org:
            return OrganizationUI(org)

        raise TraversalError
開發者ID:000fan000,項目名稱:code,代碼行數:15,代碼來源:__init__.py

示例10: authfunc

# 需要導入模塊: from vilya.models.user import User [as 別名]
# 或者: from vilya.models.user.User import get_by_name [as 別名]
def authfunc(env, username, passwd):
    if DEVELOP_MODE or (env['REMOTE_ADDR'] == '127.0.0.1'
                        and env['HTTP_HOST'] == 'localhost:8080'):
        return True

    if not passwd:
        return

    if username == 'code' and passwd == 'code':
        return True

    user = User.get_by_name(username)
    if user and user.validate_password(passwd):
        return True

    is_push = 'service=git-receive-pack' in env['QUERY_STRING'] \
              or '/git-receive-pack' in env['PATH_INFO']
    if is_push:
        pass
        # FIXME: push permission
    return True
開發者ID:leeccong,項目名稱:code,代碼行數:23,代碼來源:app_sina.py


注:本文中的vilya.models.user.User.get_by_name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。