本文整理汇总了Python中model.User.put方法的典型用法代码示例。如果您正苦于以下问题:Python User.put方法的具体用法?Python User.put怎么用?Python User.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: insert_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def insert_user(user_json):
#print "INSERT USER"
#print user_json
user_string = json.loads(user_json)
userAddress = Address(number = user_string["number"],
street = user_string["street"],
postalCode = user_string["postalCode"],
city = user_string["city"],
province = user_string["province"])
#print "pizzaId: " + user_string["pizzaId"]
userOrder = Order(qty = int(user_string["quantity"]),
size = int(user_string["pizzaSize"]),
pizza_type = int(user_string["pizzaId"]))
userAddress.put()
userOrder.put()
user = User(name = user_string["name"],
phoneNumber = user_string["phoneNumber"],
email = user_string["email"],
addressId = userAddress.key(),
orderId = userOrder.key())
user.put()
return user.key();
示例2: text_message
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def text_message(self, message):
email = extract_email(message.sender)
try:
sender = users.User(email)
except users.UserNotFoundError as e:
message.reply("You don't seem to have an account that I can find.")
appuser = User.all().filter("info = ", sender).get()
if not appuser:
appuser = User(info = sender)
appuser.put()
try:
datum = parser.parse(message.body)
except parser.ParseException as e:
message.reply("I couldn't understand you. (Message was: {msg})".format(msg = e.message))
variable = Variable.all().filter("name = ", datum["variable"]).get()
if not variable:
variable = Variable(name = datum["variable"], user = appuser)
variable.put()
value = Value(value = datum["value"], variable = variable)
value.put()
message.reply("I've logged variable {variable} as being {value}".format(sender = email,
variable = datum["variable"],
value = datum["value"]))
示例3: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def get(self):
user = self.getUser()
now = datetime.datetime.now()
if not user:
user = User(createdOn=now, lastAccessedOn=now, lastEntrySet=-1)
entries, newEntrySetNumber = self.getEntrySetForUser(user)
user.lastEntrySet = newEntrySetNumber
user.lastAccessedOn = now
try:
user.put()
userKeyToWrite = str(user.key())
except Exception as e:
logging.error(str(e))
userKeyToWrite = None
def dictionarize(e):
return {'a': e[0], 'w': e[1], 't': e[2]} #to save bandwidth
jsonifiedData = json.dumps({'userKey': userKeyToWrite, 'entries': [dictionarize(entry) for entry in entries]})
callbackParam = self.request.get('callback')
if callbackParam: #if exists, then return as JSONP
self.response.headers['Content-Type'] = 'application/javascript'
self.response.out.write('{}({});'.format(callbackParam, jsonifiedData))
else:
self.response.headers['Content-Type'] = 'application/json'
self.response.out.write(jsonifiedData)
示例4: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def get(self):
lang = self.request.get('lang')
if not lang:
lang ='en'
#********************** User Auth **************************#
user = users.get_current_user()
nickname = ''
if user:
nickname=user.nickname()
if nickname:
user_info = User.all().filter('user',nickname)
if user_info.count(1)>0:
user_info = user_info.get()
user_info.lang = lang
user_info.put()
else:
user_info =User();
user_info.user = nickname
user_info.lang = lang
user_info.put()
self.redirect('/link/'+nickname)
uri = self.request.get('uri')
if uri:
self.redirect(unquote(uri).encode('utf-8'))
else:
self.redirect('/')
示例5: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def post(self, error_msg=None):
email = self.request.get("email")
username = self.request.get("username")
users = User.all().filter('email', email)
user = User()
user.email = email
user.username = username
user.fullname = self.request.get("firstname")+" "+self.request.get("lastname")
user.birthday = datetime.datetime.strptime(self.request.get("birthday"), '%Y-%m-%d')
user.set_password(self.request.get("password")) #set password. need encrypt.
user.firstname = self.request.get("firstname")
user.lastname = self.request.get("lastname")
user.country = self.request.get("country")
gender = self.request.get("gender")
if gender:
gender_ = str(gender)[0:1]
user.gender = gender_
if users.count() == 0:
user.put()
#init() the session
sessions.Session().login_user(user)
self.redirect("/")
return
else:
error_msg = "That email address has already been registered."
template_values = {
"temp_user": user,
"error": error_msg
}
self.generate('signup.html',template_values)
示例6: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def get(self):
verification_code = self.request.get("code")
args = dict(client_id=Constants.FACEBOOK_APP_ID, redirect_uri=self.request.path_url)
if self.request.get("code"):
args["client_secret"] = Constants.FACEBOOK_APP_SECRET
args["code"] = self.request.get("code")
response = cgi.parse_qs(urllib.urlopen(
"https://graph.facebook.com/oauth/access_token?" +
urllib.urlencode(args)).read())
access_token = response["access_token"][-1]
# Download the user profile and cache a local instance of the
# basic profile info
profile = json.load(urllib.urlopen(
"https://graph.facebook.com/me?" +
urllib.urlencode(dict(access_token=access_token))))
user = User(key_name=str(profile["id"]), id=str(profile["id"]),
name=profile["name"], access_token=access_token,
profile_url=profile["link"])
user.put()
functions.set_cookie(self.response, "fb_user", str(profile["id"]),
expires=time.time() + 30 * 86400)
self.redirect("/")
else:
self.redirect(
"https://graph.facebook.com/oauth/authorize?" +
urllib.urlencode(args))
示例7: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def post(self):
self.session[LOGIN_NEXT_PAGE_KEY] = self.URL
roles=Role.all()
if roles.count() == 0:
# No roles were set up, set them up now
adminRole = Role()
adminRole.name=ROLE_ADMIN
adminRole.put()
role = Role()
role.name=ROLE_DELIVERY_GUY
role.put()
role = Role()
role.name=ROLE_COOK
role.put()
role = Role()
role.name=ROLE_AGENT
role.put()
user = User()
user.email = self.request.get("adminEmail")
user.password = "[email protected]#"
m = hashlib.md5()
encodedString = self.request.get("adminPassword").encode('ascii', errors='replace')
m.update(encodedString)
user.passwordHash = str(m.hexdigest())
user.activated = True
user.role = adminRole
user.put();
template = jinja_environment.get_template('templates/setup/setupSuccess.html')
self.printPage("Sikeres inicializálás", template.render(), True, True)
else:
template = jinja_environment.get_template('templates/setup/alreadySetUp.html')
self.printPage("Korábban inicializálva", template.render(), True, True)
示例8: create_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def create_user(google_user):
global latest_signup
user = User(
google_user=google_user
)
user.put()
latest_signup = user
return user
示例9: import_users
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def import_users(self, csv):
lines = csv.split('\n')
for line in lines:
if len(line.strip()) == 0:
continue
user = User()
user.email = line.strip()
user.put()
示例10: update_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def update_user(user_id, u_name, u_email, u_account, is_disabled, modifier_id):
user = User()
user.u_name = u_name
user.u_email = u_email
user.u_account = u_account
user.modified_time = dtutil.utcnow()
user.is_disabled = is_disabled
user.put(modifier_id)
return user
示例11: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def get(self):
logging.info("Seeding Datastore...")
for user in users:
user_ent = User(name=user[0],
age=user[1])
user_ent.put()
for article in articles:
article_ent = Article(title=article[0])
article_ent.put()
示例12: get_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def get_user(self):
'''Returns the user object on authenticated requests'''
user = users.get_current_user()
assert user
userObj = User.all().filter("email =", user.email()).fetch(1)
if not userObj:
userObj = User(email=user.email())
userObj.put()
else:
userObj = userObj[0]
return userObj
示例13: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def post(self):
_u = self.request.get('textUsername')
_e = self.request.get('emailEmail')
_pw = self.request.get('passPassword')
_pt = 0
new_user = User(us_name_st=_u,us_email_st=_e,us_password_st=_pw,us_points_int=_pt)
new_user.put()
template_values = {
'username':_u
}
template = jinja_environment.get_template('/templates/user_form.html')
self.response.out.write(template.render(template_values))
示例14: get_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def get_user(self, invite_code_name=None):
user = None
google_user = users.get_current_user()
# not logged in to google
if google_user == None:
self.redirect(users.create_login_url(self.request.uri))
return None
user = User.get_by_google_user(google_user)
# user was not in our database, so its a first-time login
if user == None:
user = User(google_user = google_user,
first_name='',
last_name='',
email=google_user.email()
)
user.put()
# now we have a user, but are they whitelisted
# or do they have an invite?
if invite_code_name != None:
invite_code = InviteCode.get_by_name(invite_code_name)
# is this code valid?
if invite_code != None and invite_code.use_code() == True:
user.is_whitelisted = True
user.put()
else:
user = None
elif user.is_whitelisted != True:
user = None
# this enables admins to see pages in any user's context
if self.request.get('admin', None) == 'true' and user.email in admins:
user_email = self.request.get('user_email')
user = User.get_by_email(user_email)
# if we've gotten this far and the user is none, it means this user is
# not whitelisted
if user == None:
self.redirect(users.create_logout_url('/no-invite'))
return user
示例15: login_google_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import put [as 别名]
def login_google_user(self):
"""
associate the sesion object with google user object.
"""
session = self.session
google_user = users.get_current_user()
if google_user and (session.user is None):
users_ = User.all().filter("email", google_user.email())
if users_.count() == 0:
user = User()
user.email = google_user.email()
user.username = google_user.nickname()
user.put()
else:
user = users_[0]
self.login_user(user)