本文整理汇总了Python中model.User.all方法的典型用法代码示例。如果您正苦于以下问题:Python User.all方法的具体用法?Python User.all怎么用?Python User.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def get(self):
if(not isUserAdmin(self)):
self.session[LOGIN_NEXT_PAGE_KEY] = self.URL
self.redirect("/")
return
pageText=self.request.get("page")
pageSize=20
actualPage=0
if (pageText!=None and pageText!=""):
actualPage=int(pageText)-1
orderByText=self.request.get("order")
if (orderByText==None or orderByText==""):
orderByText='familyName'
userCount=User.all().count()
roles=Role.all().order("name")
usersToDisplay=User.all().order(orderByText).run(offset=actualPage*pageSize, limit=pageSize)
pages=[]
corrector=1
if (userCount/pageSize) * pageSize == userCount:
corrector=0
for i in range(0,userCount/pageSize + corrector):
pages.append(i+1)
template_values={
'page':actualPage+1,
'pages':pages,
'userList':usersToDisplay,
'order':orderByText,
'roles':roles
}
if actualPage < userCount/ pageSize - 1 - corrector:
template_values["nextPage"]=actualPage + 2
if actualPage > 0:
template_values["nextPage"]=actualPage
template = jinja_environment.get_template('templates/userList.html')
self.printPage("Felhasznalok", template.render(template_values), False, False)
示例2: initialize
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def initialize(self, request, response):
webapp.RequestHandler.initialize(self, request, response)
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"
from model import g_blog, User
self.blog = g_blog
self.login_user = users.get_current_user()
self.is_login = self.login_user != None
self.loginurl = users.create_login_url(self.request.uri)
self.logouturl = users.create_logout_url(self.request.uri)
self.is_admin = users.is_current_user_admin()
if self.is_admin:
self.auth = "admin"
self.author = User.all().filter("email =", self.login_user.email()).get()
if not self.author:
self.author = User(dispname=self.login_user.nickname(), email=self.login_user.email())
self.author.isadmin = True
self.author.user = self.login_user
self.author.put()
elif self.is_login:
self.author = User.all().filter("email =", self.login_user.email()).get()
if self.author:
self.auth = "author"
else:
self.auth = "login"
else:
self.auth = "guest"
try:
self.referer = self.request.headers["referer"]
except:
self.referer = None
self.template_vals = {"self": self, "blog": self.blog, "current": self.current}
示例3: initialize
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def initialize(self, request, response):
self.current='home'
webapp.RequestHandler.initialize(self, request, response)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from model import User,Blog
self.blog = Blog.getBlog()
self.login_user = users.get_current_user()
self.is_login = (self.login_user != None)
self.loginurl=users.create_login_url(self.request.uri)
self.logouturl=users.create_logout_url(self.request.uri)
self.is_admin = users.is_current_user_admin()
if self.is_admin:
self.auth = 'admin'
self.author=User.all().filter('email =',self.login_user.email()).get()
if not self.author:
self.author=User(dispname=self.login_user.nickname(),email=self.login_user.email())
self.author.isadmin=True
self.author.user=self.login_user
self.author.put()
elif self.is_login:
self.author=User.all().filter('email =',self.login_user.email()).get()
if self.author:
self.auth='author'
else:
self.auth = 'login'
else:
self.auth = 'guest'
try:
self.referer = self.request.headers['referer']
except:
self.referer = None
self.template_vals = {'self':self,'blog':self.blog,'current':self.current}
示例4: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def get(self):
user = self.get_user()
# Update enabled state if requested
send_digest = self.request.get('send_digest')
if send_digest == '1':
user.send_digest = True
user.put()
elif send_digest == '0':
user.send_digest = False
user.put()
send_reminder = self.request.get('send_reminder')
if send_reminder == '1':
user.send_reminder = True
user.put()
elif send_reminder == '0':
user.send_reminder = False
user.put()
# Fetch user list and display
raw_users = User.all().order('email').fetch(500)
all_users = [(u, u.email) for u in raw_users]
template_values = {
'current_user' : user,
'all_users': all_users,
'config': config,
}
self.render('index', template_values)
示例5: login
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def login(login_name, login_password):
if login_name == ANONYMOUS_ACCOUNT_NAME:
usermodel = get_user(u_account=login_name)
else:
try:
login_name = decrypt_password(login_name)
login_password = decrypt_password(login_password)
except:
raise LoginFailedError()
query = User.all()
query.filter("u_account =", login_name, parenthesis="(")
query.filter("u_email =", login_name, logic="or", parenthesis=")")
password = encrypt_password(login_password)
query.filter("u_password =", password)
if query.count() > 0:
usermodel = query.fetch(1)[0]
_attach_userprops(usermodel)
else:
raise LoginFailedError()
usermodel.logined_times += 1
update_user_logined_info(usermodel.key(), usermodel.key())
token = Token(usermodel.uid, anonymous=usermodel.u_account == ANONYMOUS_ACCOUNT_NAME)
token.userName = usermodel.u_name
token.accountName = usermodel.u_account
return token
示例6: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def get(handler, response):
lat = handler.request.get('lat')
lon = handler.request.get('lng')
response.users = User.proximity_fetch(
User.all(),
geotypes.Point(float(lat),float(lon)),
)
示例7: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def get(self):
if(not isUserAdmin(self)):
self.session[LOGIN_NEXT_PAGE_KEY] = self.URL
self.redirect("/")
return
today = datetime.datetime.now(timeZone)
twoWeeksAgo = today + datetime.timedelta(days = - 14)
unseenUsers = User.all().filter("lastOrder < ", twoWeeksAgo)
unseenUsersOrdered = sorted(unseenUsers, key=getLastOrderDate)
taskedUsers = User.all().filter("taskList >= ", None)
template_values={
'users': itertools.chain(taskedUsers, unseenUsersOrdered),
}
template = jinja_environment.get_template('templates/crm/crmTaskList.html')
self.printPage("Felhasználók", template.render(template_values), False, False)
示例8: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def post(self):
""" Changes the current users nickname """
new_nickname = self.request.get('nickname')
if not new_nickname:
self.error(409)
return
new_nickname_lower = new_nickname.lower()
user = utils.get_current_user()
if not user:
self.error(403)
return
if new_nickname != user.nickname:
others = User.all().filter('nickname_lower =', new_nickname_lower).get()
if others and others.key() != user.key():
self.error(409)
return
user.nickname_lower = new_nickname_lower
user.nickname = new_nickname
user.save()
self.response.headers['Content-Type'] = 'application/json; charset=utf-8'
self.response.headers['Access-Control-Allow-Origin'] = '*'
self.response.out.write(json.dumps(user.to_struct()))
示例9: post
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [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)
示例10: text_message
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [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"]))
示例11: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def get(self):
nowtime = datetime.datetime.now()
users = User.all().filter("sync_time <=", nowtime)
for user in users:
fqueue = taskqueue.Queue(name='fetch')
ftask = taskqueue.Task(url='/task/fetch/', params=dict(uid=user.key().name()))
fqueue.add(ftask)
示例12: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [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('/')
示例13: DeleteOpenID
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def DeleteOpenID(self,request):
openid = request.get("openid")
users = User.all().filter('openids', openid)
if users.count() != 0:
user = users[0]
user.openids.remove(db.Category(openid.strip().encode('utf8')))
user.put()
return True
示例14: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def get(self):
all_users = User.all().filter("send_reminder =", True).fetch(500)
for user in all_users:
if not snippet_exists(user, date_for_new_snippet()):
logging.info('reminding: '+ user.email)
taskqueue.add(url='/onereminder', params={'email': user.email})
else:
logging.info('skipping: '+user.email)
示例15: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import all [as 别名]
def get(self):
q = User.all()
template_values = {
'list_users':q.run(limit=10)
}
template = jinja_environment.get_template('/templates/user_list.html')
self.response.out.write(template.render(template_values))