本文整理汇总了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:])
示例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())
示例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
示例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
示例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')
示例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
示例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
示例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')
示例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
示例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