本文整理汇总了Python中models.profile.Profile.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.gql方法的具体用法?Python Profile.gql怎么用?Python Profile.gql使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.profile.Profile
的用法示例。
在下文中一共展示了Profile.gql方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: verify_access
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def verify_access(self, *args):
user = users.GetCurrentUser()
if user:
profile = Profile.gql("WHERE user = :1", user)
current_profile = profile.get()
if role == current_profile.role:
handler_method(self, *args)
return
self.response.out.write('<html><head></head><body>Access denied</body></html>')
示例2: validate
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def validate(self, email, password):
if not email_pattern.match(email):
raise Exception("Email format is not right")
if not password or not email:
raise Exception("Password and email cannot be empty")
profile = Profile.gql('WHERE user_email=:1', email).get()
if profile:
raise Exception("This email is already occupied.")
示例3: get
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def get(self):
user = users.get_current_user()
if user:
profile = Profile.gql("WHERE user = :1", user).get()
if not profile:
self.redirect("/profiles/new")
return
self.redirect("/dashboard")
else:
self.redirect(users.create_login_url(self.request.uri))
示例4: get
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def get(self, meeting_key=None, user_name=None):
login_user = self.get_current_user()
m = Meeting.get(meeting_key)
if m is None:
return self.error(404)
if m.creator != login_user:
return self.error(401)
profile = Profile.gql('WHERE nickname = :1', user_name).get()
m.delete_member(profile.get_user())
return self.redirect_back()
示例5: validate
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def validate(self, profile):
nickname = self.request.get('nickname', '').strip()
if nickname:
if Profile.gql('WHERE nickname=:1 AND __key__ != :2',
nickname,
profile.key()).get():
raise Exception('Nickname already been taken')
else:
raise Exception('Nickname cannot be empty')
fullname = self.request.get('fullname', '').strip()
if not fullname:
raise Exception('Full name cannot be empty')
示例6: post
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def post(self, meeting_key=None):
login_user = self.get_current_user()
m = Meeting.get(meeting_key)
if m is None:
return self.error(404)
if m.creator != login_user:
return self.error(401)
user_name = self.request.get('user_name')
profile = Profile.gql('WHERE nickname = :1', user_name).get()
if profile:
m.add_member(profile.get_user())
return self.redirect_back()
示例7: get
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def get(self):
if Profile.gql('WHERE user_email = :1', settings.NEWS_USER).get():
self.response.out.write('Already exist')
return
news = create_user(settings.NEWS_USER, 'halihalinews').get_user()
#user = create_user('[email protected]', '1111').get_user()
#person = create_user('[email protected]', '1111').get_user()
#grade = create_user('[email protected]', '1111').get_user()
#for i in range(1, 21):
# ut = create_user('user_%[email protected]' % i, '1111').get_user()
# Follow.new(ut, user)
# Follow.new(person, ut)
#Follow.new(user, person)
#Follow.new(person, grade)
self.response.out.write('OK')
示例8: new
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def new(cls, user, content, attachment='', meeting=None):
from helpers import filter_blip
from models.profile import Profile
if content:
content, user_names, urls = filter_blip(content)
to_user = None
if content.startswith('@'):
profile = Profile.gql('WHERE nickname = :1', user_names[0]).get()
if profile:
to_user = profile.get_user()
blip = cls(text=content, user=user,
attachment=attachment, to_user=to_user,
meeting=meeting)
blip.put()
link = BlipLink.new(blip.user, blip)
task = taskqueue.Task(url='/task/blip/deliver',
params={'key': blip.key()})
task.add(queue_name='status-delivery')
return blip
示例9: get
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def get(self, user_name=None):
login_user = self.get_current_user()
if user_name is None:
return self.redirect('/signin')
profile = Profile.gql('WHERE nickname=:1', user_name).get()
if not profile or not profile.is_active:
return self.error(404)
user = profile.get_user()
is_self = user == login_user
has_followed = False
if not is_self:
has_followed = Follow.gql('WHERE from_user = :1 AND to_user = :2',
login_user, user).get() is not None
followers = Follow.who_subscribe_you(user)
follower_profiles = []
for f in followers:
c, p = Profile.get_or_create_from_user(f.from_user)
follower_profiles.append(p)
followees = Follow.your_subscribers(user)
followee_profiles = []
for f in followees:
c, p = Profile.get_or_create_from_user(f.to_user)
followee_profiles.append(p)
try:
page = int(self.request.get('page', '1'))
except ValueError:
page = 1
has_followed = Follow.gql('WHERE from_user = :1 AND to_user =:2',
login_user,
user).get()
pagesize = settings.BLIP_PAGE_SIZE
paginator = SimplePaginator(Blip.qs_for_author(user),
page, pagesize)
blips = each_profiles(paginator.object_list)
return self.render('user_page.html', locals())
示例10: post
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def post(self):
if not login_using_local():
return self.error(404)
email = self.request.get('email')
password = self.request.get('password')
continue_to = self.request.get('continue_to', '/')
google_login_url = users.create_login_url(continue_to)
errors = []
local_user = UserAuth.gql('WHERE email=:1', email).get()
if local_user and self.authenticate(local_user, password):
login_user = local_user.get_user()
profile = Profile.gql('WHERE user = :1', login_user).get()
if not profile:
created, profile = Profile.get_or_create_from_user(login_user)
if created:
self.redirect('/profile/edit')
return self.redirect(continue_to)
else:
errors.append('Login error, please relogin again')
using_google = login_using_google()
return self.render('signin.html', locals())
示例11: call
# 需要导入模块: from models.profile import Profile [as 别名]
# 或者: from models.profile.Profile import gql [as 别名]
def call(self, out):
if Profile.gql('WHERE user_email = :1', settings.NEWS_USER).get():
out.write('News user already exist')
return
news = create_user(settings.NEWS_USER,
settings.NEWS_PASSWORD).get_user()