本文整理汇总了Python中user.User.put方法的典型用法代码示例。如果您正苦于以下问题:Python User.put方法的具体用法?Python User.put怎么用?Python User.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user.User
的用法示例。
在下文中一共展示了User.put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def get(self):
name = self.request.get('name')
email = self.request.get('post')
user = User(name=name, email=email)
user.put()
message = '<ul><li>%s, %s</li></ul>' % (name, email)
self.response.write(message)
示例2: post
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def post(self):
""" Handle the sign-up request. """
email = self.request.get("email")
pwd = self.request.get("password")
verify = self.request.get("verify")
# there is verification on browser by JS, but validating again won't hurt
if not self._validate(email, pwd, verify):
logging.error("How could the invalid input pass the JS test? @auth.SignUpHandler.post()")
self.redirect("/signup")
return
if User.exists(email):
# telling user that the email has been taken
self._error("Email registered by others")
else:
hashed = encrypt.hash_pwd(email, pwd)
u = User(email=email,
pwd_hashed=hashed,
parent=utils.get_key_public('User'))
u.put()
self._init_user(u)
self._set_id_cookie(email)
self.redirect('/me')
示例3: get
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def get(self):
http = decorator.http()
service = build("plus", "v1", http=http)
# Call the service using the authorized Http object.
request = service.people().get(userId="me")
response = request.execute(http=http)
user_id=response['id']
name=response['displayName']
image=response['image']['url']
self.render("home.html")
try:
# Get the db.User that represents the user on whose behalf the
# consumer is making this request.
#user = oauth.get_current_user("https://www.googleapis.com/auth/userinfo.email")
if response:
greeting = ('Welcome, %s! (<a href="%s">sign out</a>)' %
(name, users.create_logout_url('/')))
entity = User.by_user_id(user_id)
self.write(greeting)
if entity is None:
entity = User(user_id=user_id, picture=image, name=name)
entity.put()
template_values = {"user":entity, "greeting":greeting}
#self.redirect('/profile')
else:
self.render("home.html")
except oauth.OAuthRequestError, e:
self.write("Error")
示例4: post
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def post(self):
results_template = env.get_template('results.html')
template_variables = {
'message':self.request.get("message"),
'name':self.request.get("name"),
'email':self.request.get("email")
}
u = User(name=template_variables['name'], email=template_variables['email'])
u.put()
self.response.out.write(results_template.render(template_variables))
示例5: post
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def post(self):
user = User()
user.picture = "http://upload.wikimedia.org/wikipedia/commons/7/7f/Emma_Watson_2013.jpg"
user.email = self.request.get('email')
user.age = int(self.request.get('age'))
user.tagline = self.request.get('mission')
user.tags = self.request.get('tags').split(",")
user.intersts = self.request.get('interests')
user.put()
template_values = {"user":user}
self.render("profile.html", **template_values)
示例6: create_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def create_user(self, request):
"""Creates a User. Requires a unique username.
"""
if User.query(User.name == request.user_name).get():
raise endpoints.ConflictException(
'A User with that name already exists!')
user = User(name=request.user_name, email=request.email)
user.put()
# return StringMessage(message='User {} created!'.format(
# request.user_name))
return user.to_form()
示例7: add_user
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def add_user(self, u_name, u_type):
u = User(name = u_name, type = u_type)
self.response.write("""
<p>
<b>Usuario adicionado:</b><br/>
<b>Nome: </b> %s <br/>
<b>Tipo: </b> %s
</p>
""" %(u.name, u.type))
u.put()
Mailer.send_mail(self, "[email protected]", "Novo usuario", "Novo usuario cadastrado:\n\tNome: %s\n\tTipo: %s" %(u_name, u_type))
示例8: post
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def post(self):
#get parameters out of the request
user_username = self.request.get('username')
user_password = self.request.get('password')
username = valid_username(user_username)
password = valid_password(user_password)
params = {"username": username, "password": password}
errors = {"username": "That is not a valid username.",
"password": "That is not a valid password."}
#login is validated
if username and password:
user_logged_in = self.check_if_logged_in()[0]
if user_logged_in:
previous_url = memcache.get("current path")
self.redirect(previous_url)
if not user_logged_in:
#if first time, set a cookie
new_cookie_val = make_secure_val(username)
self.response.headers.add_header('Set-Cookie', 'username = %s' % str(new_cookie_val), path = '/')
u = User(username = username, password = new_cookie_val)
u.put()
#need to change this to url just came from if can
previous_url = memcache.get("current path")
self.redirect(previous_url)
else:
#figure out which is in error
username_error = ""
password_error = ""
password = ""
for param in params:
if params[param] == False or params[param] == None:
if param == 'username':
username_error = errors[param]
if param == 'password':
password_error = errors[param]
self.write_form(username_error, password_error,user_username, password)
示例9: post
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def post(self):
from cgi import escape
user_username = self.request.get('username')
user_password = self.request.get('password')
user_verify = self.request.get('verify')
user_email = self.request.get('email')
username = escape(user_username)
email = escape(user_email)
if self.validate(username, user_password, user_verify, email):
u = User(username=username,
password_hash=User.get_password_hash(user_password), email=email)
u.put()
self.response.headers.add_header('Set-Cookie', 'user=%s; Path=/' %
self.generate_cookie(u.key().id()))
self.redirect('/')
else:
self.render_form(username, email)
示例10: get
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def get(self):
gh_code = self.get_query_argument('code', None)
if not gh_code:
return self.redirect('/')
gh_oauth = OAuth(gh_code)
yield gh_oauth.set_access_token()
if not gh_oauth.access_token:
return self.redirect('/')
user_data = yield gh_oauth.get_user_data()
login = user_data['login']
user = yield User.get(login=login)
if not user:
user = User(login, data=user_data, gh_token=gh_oauth.access_token)
yield user.put()
self.set_secure_cookie('token', user.token)
self.redirect('/')
示例11: get
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def get(self):
username = self.request.get("user")
password = self.request.get("password")
email = self.request.get("email")
self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
if not username or not password or not email:
# some fields were missing in the request
self.response.write(json_error('invalid', ''))
else:
query_user = User.query(User.username == username).fetch()
query_email = User.query(User.email == email).fetch()
if query_user:
# a user with this username exists already
self.response.write(json_error('failure', 'username'))
elif query_email:
# a user with this email exists already
self.response.write(json_error('failure', 'email'))
else:
# create a new user with the data recieved
user = User(username = username, pswd = password, email = email)
db_result = user.put()
self.response.write(register_response('ok'))
示例12: post
# 需要导入模块: from user import User [as 别名]
# 或者: from user.User import put [as 别名]
def post(self):
# get parameters out of the request
user_username = self.request.get("username")
user_password = self.request.get("password")
user_vpassword = self.request.get("verify")
user_email = self.request.get("email")
username = valid_username(user_username)
password = valid_password(user_password)
vpassword = valid_password(user_vpassword)
email = valid_email(user_email)
match = password == vpassword
params = {"username": username, "password": password, "vpassword": match, "email": email}
errors = {
"username": "That is not a valid username.",
"password": "That is not a valid password.",
"vpassword": "The passwords don't match.",
"email": "That is not a valid email address.",
}
been_here = visit_cookie_str = self.request.cookies.get("username")
users = db.GqlQuery("SELECT * from User")
error_flag = False
for user in users:
if user.username == username:
params["username"] = False
errors["username"] = "User already exists."
error_flag = True
if not error_flag and username and password:
# log them in
if not self.check_if_logged_in()[0]:
self.log_in_user(username)
# sore user and redirect them to main page
new_cookie_val = make_secure_val(username)
u = User(username=username, password=new_cookie_val)
u.put()
self.redirect("/")
else:
# figure out which is in error
username_error = ""
password_error = ""
matchpw_error = ""
email_error = ""
password = ""
vpassword = ""
for param in params:
if params[param] == False or params[param] == None:
if param == "username":
username_error = errors[param]
if param == "password":
password_error = errors[param]
if param == "vpassword":
matchpw_error = errors[param]
if param == "email":
email_error = errors[param]
self.write_form(
username_error,
password_error,
matchpw_error,
email_error,
user_username,
password,
vpassword,
user_email,
)