本文整理汇总了Python中users.User.put方法的典型用法代码示例。如果您正苦于以下问题:Python User.put方法的具体用法?Python User.put怎么用?Python User.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类users.User
的用法示例。
在下文中一共展示了User.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signUp
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import put [as 别名]
def signUp(username, userid):
CONST_ERROR_ALR_REG = 0
CONST_OPTION_REG_SUCCESS = 1
user_query = (User.query()).fetch() # Get all users in the datastore
# If this user already exists
if (any(q.user_id == userid for q in user_query)):
return CONST_ERROR_ALR_REG
# Else if this user has not been registered
else:
new_user = User(user_name=str(username), user_id=userid)
new_user.put()
return CONST_OPTION_REG_SUCCESS
示例2: post
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import put [as 别名]
def post(self):
"""Function that gets called when form is submitted"""
error_username = ""
error_password = ""
error_email = ""
entered_username = cgi.escape(self.request.get("username"))
if cgi.escape(self.request.get("username")) == "" :
error_username = "Please enter username"
elif verify_username(entered_username) == None:
error_username = "Username not valid"
else :
query= db.GqlQuery("select * from User where username = :1",
entered_username)
if query.get():
error_username = "Username already exists"
entered_password = cgi.escape(self.request.get("password"))
entered_verify = cgi.escape(self.request.get("verify"))
if entered_password == "":
error_password = "Please enter password"
elif entered_verify == "":
error_password = "Please enter a matching password"
elif entered_password != entered_verify :
error_password = "Passwords do not match"
entered_email = cgi.escape(self.request.get("email"))
if entered_email and verify_email(entered_email) == None:
error_email = "Email not valid"
if (error_username != "" or error_password !="" or error_email!=""):
self.show_form(error_username,
error_password,
error_email,
entered_username,
entered_email)
else:
new_user = User(username=entered_username,
hashed_pwd=make_hashed_password(entered_password),
email=entered_email)
new_user.put()
self.set_secure_cookie('user_id',str(new_user.key().id()))
self.redirect("/profile")
示例3: post
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import put [as 别名]
def post(self):
"""Check if the username is already taken. If not create a new user."""
users = db.GqlQuery("select * from User order by created desc")
username = self.request.get('username')
password = self.request.get('password')
verify = self.request.get('verify')
have_error = False
error_msg = ""
# check if all values are valid input, and passwords match
if not valid_username(username):
error_msg = "Username must be between 3 and 20 alphanumeric characters."
have_error = True
else:
for user in users:
if user.username == username:
error_msg = "Username is already in use."
have_error = True
if not valid_password(password):
error_msg = "Password must be between 3 and 20 characters."
have_error = True
if not password == verify:
error_msg = "Passwords do not match."
have_error = True
# if something is invalid, render page again with error message
if have_error:
self.render('register.html', username=username, error_msg=error_msg)
else:
#otherwise, create a new user, and redirect to main page
user = User(username=username, password=password)
user.put()
username = str(username)
self.response.headers.add_header('Set-Cookie', 'user_id=%s; Path=/' % username)
self.redirect('/')
示例4: update_database
# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import put [as 别名]
def update_database(data):
print('updating db')
# start upload text
if int(data['rows_saved']) > 0:
if 'saved' in data:
saved = data['saved']
if 'addresses' in saved:
for addresses in saved['addresses']:
address = Address()
where = {'id': addresses['id']}
data = {'address_id': addresses['address_id']}
address.put(where=where, data=data)
if 'colors' in saved:
for colors in saved['colors']:
color = Colored()
where = {'id': colors['id']}
data = {'color_id': colors['color_id']}
color.put(where=where, data=data)
if 'cards' in saved:
for cards in saved['cards']:
card = Card()
where = {'id': cards['id']}
data = {'card_id': cards['card_id']}
card.put(where=where, data=data)
if 'credits' in saved:
for credit in saved['credits']:
credits = Credit()
where = {'id': credit['id']}
data = {'credit_id': credit['credit_id']}
credits.put(where=where, data=data)
if 'companies' in saved:
for companies in saved['companies']:
company = Company()
where = {'id': companies['id']}
data = {'company_id': companies['company_id']}
company.put(where=where, data=data)
if 'custids' in saved:
for custids in saved['custids']:
custid = Custid()
where = {'id': custids['id']}
data = {'cust_id': custids['cust_id']}
custid.put(where=where, data=data)
if 'deliveries' in saved:
for deliveries in saved['deliveries']:
delivery = Delivery()
where = {'id': deliveries['id']}
data = {'delivery_id': deliveries['delivery_id']}
delivery.put(where=where, data=data)
if 'discounts' in saved:
for discounts in saved['discounts']:
discount = Discount()
where = {'id': discounts['id']}
data = {'discount_id': discounts['discount_id']}
discount.put(where=where, data=data)
if 'inventories' in saved:
for inventories in saved['inventories']:
inventory = Inventory()
where = {'id': inventories['id']}
data = {'inventory_id': inventories['inventory_id']}
inventory.put(where=where, data=data)
if 'inventory_items' in saved:
for inventory_items in saved['inventory_items']:
inventory_item = InventoryItem()
where = {'id': inventory_items['id']}
data = {'item_id': inventory_items['item_id']}
inventory_item.put(where=where, data=data)
if 'invoices' in saved:
for invoices in saved['invoices']:
invoice = Invoice()
where = {'id': invoices['id']}
data = {'invoice_id': invoices['invoice_id']}
invoice.put(where=where, data=data)
if 'invoice_items' in saved:
for invoice_items in saved['invoice_items']:
invoice_item = InvoiceItem()
where = {'id': invoice_items['id']}
data = {'invoice_items_id': invoice_items['invoice_items_id']}
invoice_item.put(where=where, data=data)
if 'memos' in saved:
for memos in saved['memos']:
memo = Memo()
where = {'id': memos['id']}
data = {'memo_id': memos['memo_id']}
memo.put(where=where, data=data)
if 'printers' in saved:
for printers in saved['printers']:
printer = Printer()
where = {'id': printers['id']}
#.........这里部分代码省略.........