- This code is working, but...
- is there a better or shorter way to accomplish this.
~ thanks for help.
Rob
{{
# QUESTION:
# is there a more direct way of accomplishing this?
# file: userinfo.html (a web2py view)
# I'm logged in as
# user: jdoe
# this will return first_name and last_name of any OTHER user in
db.auth_user
# if they exist
# I want to access information on ANOTHER user: jsmith
# jdoe will type in to a form (not shown here):
# jsmith
# to see if they are a user.
# db.auth_user holds:
# username: jsmith
# first_name: John
# last_name: Smith
# just use variable myuser for this example snippet
myuser = 'jsmith'
# attempt to grap the first and last name of user jsmith
first = db(db.auth_user.username == myuser).select(db.auth_user.first_name
).as_list()
second = db(db.auth_user.username == myuser).select(db.auth_user.last_name).
as_list()
# see if the query returned anything. i.e. test if username is in database
if len(first)>0:
s1=first[0]['first_name']
s2 =second[0]['last_name']
# prints: John Smith
= s1 + ' ' + s2
else:
= "user not a member of site"
pass
}}
--
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.