当前位置: 首页>>代码示例>>Python>>正文


Python User.get_by_key_name方法代码示例

本文整理汇总了Python中model.user.User.get_by_key_name方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_by_key_name方法的具体用法?Python User.get_by_key_name怎么用?Python User.get_by_key_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在model.user.User的用法示例。


在下文中一共展示了User.get_by_key_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle_facebook_login

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
 def handle_facebook_login(self):
     access_token = self.request.get('access_token')
     user_id = self.request.get('user_id')
     profile_url = 'https://graph.facebook.com/me?access_token=%s'
     profile = json.loads(urlfetch.fetch(profile_url%access_token).content)
     logging.info('Facebook Login:: ')
     logging.info(profile)
     id = profile['id']
     if not id == user_id:
         response = {"success": False, "error": "Facebook ids don't match."}
     else:
         if 'email' in profile:
             email = profile['email']
         else:
             email = id
         user = User.get_by_key_name(email)
         device_token = self.request.get('token_hex')
         if not user:
             user = User.create(email, profile['first_name'], profile['last_name'], device_token)
             ThirdPartyUser.create('FB', user, access_token, id)
             profile_picture = self.get_profile_picture(id)
             User.update(email, profile_picture=profile_picture, device_token=device_token)
         else:
             User.update(email, device_token=device_token)
         util.set_session(email)
         response = {"success": True, "email": email, "first_name": user.first_name, "last_name": user.last_name}
     return response
开发者ID:mschwalb,项目名称:photobout,代码行数:29,代码来源:users.py

示例2: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
 def get(self):
     response = {}
     response['data'] = []
     follower_email = self.request.get('user_id')
     if follower_email:
         follower = User.get_by_key_name(follower_email)
         if follower:
             followings = Following.for_user(follower)
             for following in followings:
                 user = User.get_by_key_name(following.email)
                 user_dict = {}
                 user_dict['name'] = user.name
                 user_dict['id'] = user.email
                 user_dict['profile_picture'] = user.profile_picture
                 response['data'].append(user_dict)
     self.response.write(json.dumps(response))
开发者ID:mschwalb,项目名称:photobout,代码行数:18,代码来源:users.py

示例3: _user_logged_in

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
def _user_logged_in(handler):
    session = get_current_session()
    if session.is_active() and 'email' in session:
        if User.get_by_key_name(session['email']):
            return True
        session.terminate()
    return False
开发者ID:mschwalb,项目名称:photobout,代码行数:9,代码来源:util.py

示例4: get_companies_for

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
 def get_companies_for(self, email):
     members = CompanyMember.all().filter('user_id =', email)
     companies = []
     for company_member in members.fetch(100):
         user = User.get_by_key_name(company_member.user_id)
         companies.append({'value' : company_member.parent().key().id(), 'name' : company_member.parent().name, 'member_name' : user.name, 'member_id' : company_member.key().id()})
     return companies
开发者ID:aiyappaganesh,项目名称:underdogs,代码行数:9,代码来源:temp.py

示例5: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
 def get(self):
     path = 'list_member.html'
     company_id = int(str(self['company_id']))
     c = Company.get_by_id(company_id)
     if not c:
         self.write('no company')
         return
     session = get_current_session()
     user_id = session['me_email']
     access_type = self.get_access_type(c, user_id)
     q = CompanyMember.all().ancestor(c)
     users = [{'name': User.get_by_key_name(company_member.user_id).name, 'influence': company_member.influence, 'expertise': company_member.expertise} for company_member in q]
     donuts = 2
     donuts -= 1
     donut_size = 80-(5*donuts)
     score_font_size = 40-(3*donuts)
     tooltip_font_size = 14-donuts
     template_values = {'company_id': company_id,
                        'name': c.name,
                        'influence': c.influence_avg if c.influence_avg else 0.0,
                        'expertise': c.expertise_avg if c.expertise_avg else [],
                        'users': users,
                        'access_type': access_type,
                        'admin_id': user_id,
                        'donut_size': donut_size,
                        'score_font_size': score_font_size,
                        'tooltip_font_size': tooltip_font_size}
     self.write(self.get_rendered_html(path, template_values), 200)
开发者ID:aiyappaganesh,项目名称:underdogs,代码行数:30,代码来源:add_member.py

示例6: update

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
    def update(self):
        if self._request_method == 'post':
            from model.user import User
            
            user = User.get_by_key_name(self.session['user']['gmail'])

            u = self.params['user']
            d = self.params['date']['select']
            
            website = u['website']
            
            from datetime import date
            from google.appengine.ext import db
            
            user.email = u['email']
            user.profile = u['profile']
            user.gender = int(u['gender'])
            user.birthdate = date(int(d['y']),int(d['m']),int(d['d']))
            if len(u['website']) > 0:
                try:
                    link = db.Link(u['website'])
                    user.website = link
                except:
                    pass
            else:
                user.website = None
            user.put()
            
            self.redirect('/settings?status=updated')
        else:
            self.render(text='Invalid Request')
开发者ID:chihchun,项目名称:bebebe,代码行数:33,代码来源:account.py

示例7: new_or_existing_ga

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
def new_or_existing_ga(user, alias_suggestion=None):
    #id = unicode(type(user).__name__.lower() +':'+ user.user_id())
    id = unicode('ah:'+ user.user_id())
    entity = User.get_by_key_name(id)
    if not entity:
        entity = User(key_name=id, email=user.email())
        entity.put()
        logger.debug("Created user %s (%s)", entity.email, entity.key().name())
        #if alias_suggestion and not find_alias(alias_suggestion):
        #    alias = new_alias(entity, alias_suggestion)
        #else:
        #    alias = new_alias_for(entity)
        #assert alias, "FIXME: Cannot create Alias for %s" % user.email()
        #alias.put()
        #logger.debug("Created alias %s for user (%s).", alias.handle, entity.key().name())

    elif entity.email != user.email():
        entity.email = user.email()
        entity.put()
        #alias = new_alias_for(entity)
        #if alias:
        #    logger.debug("Updating user %s for alias %s. ", user.email(), newalias)
        #    alias.put()
        #else:
        #    logger.info("New alias not available for user %s. ", user.email())

    return entity
开发者ID:dotmpe,项目名称:Blue-Lines,代码行数:29,代码来源:api.py

示例8: new_or_existing_email

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
def new_or_existing_email(email):
    mbox_sha1 = hashlib.sha1(email).hexdigest()
    id = unicode('bl:'+ mbox_sha1)
    entity = User.get_by_key_name(id)
    if not entity:
        entity = User(key_name=id, email=email)
        entity.put()
    else:
        logger.error("TODO: implement user authentication. ")
    return entity
开发者ID:dotmpe,项目名称:Blue-Lines,代码行数:12,代码来源:api.py

示例9: send_push_notification

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
def send_push_notification(email, message, bout_id=None):
    device_token = User.get_by_key_name(email).device_token
    if device_token:
        logging.info('... sending notification')
        logging.info(email)
        logging.info(message)
        logging.info(bout_id)
        apns = APNs(use_sandbox=False, cert_file='PhotoboutProdCert.pem', key_file='PhotoboutProdKeyNoEnc.pem')
        payload = Payload(alert=message, sound="default", badge=1, custom={'bid':bout_id})
        apns.gateway_server.send_notification(device_token, payload)
开发者ID:mschwalb,项目名称:photobout,代码行数:12,代码来源:util.py

示例10: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
 def get(self, network):
     config = configs[network]['profile']
     handler = Auth.get_handler(network, config)
     redirect_url = handler.fetch_and_save_profile(self)
     session = get_current_session()
     user = User.get_by_key_name(session['me_email'])
     data_pull_handler = self.get_profile_data_pull_handler(network)
     third_party_profile_data = ThirdPartyProfileData.get_by_key_name(network, parent=user)
     data_pull_handler(third_party_profile_data)
     self.redirect(redirect_url)
开发者ID:aiyappaganesh,项目名称:underdogs,代码行数:12,代码来源:auth.py

示例11: get

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
 def get(self):
     company = Company.get_by_id(int(str(self['company_id'])))
     if not company:
         self.write('no company')
         return
     members = CompanyMember.all().ancestor(company)
     ret_val = []
     for member in members.fetch(1000):
         user = User.get_by_key_name(member.user_id)
         ret_val.append({'name' : user.name, 'id' : member.key().id()})
     self.write(json.dumps(ret_val))
开发者ID:aiyappaganesh,项目名称:underdogs,代码行数:13,代码来源:temp.py

示例12: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
 def post(self):
     follower_user = util.get_user_from_session()
     following_email = self.request.get('following')
     following_user = User.get_by_key_name(following_email)
     if following_user:
         follower = Follower.get_by_key_name(follower_user.email, parent=following_user)
         if follower:
             follower.delete()
         following = Following.get_by_key_name(following_email, parent=follower_user)
         if following:
             following.delete()
开发者ID:mschwalb,项目名称:photobout,代码行数:13,代码来源:users.py

示例13: fetch_and_save_github_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
def fetch_and_save_github_user(access_token):
	response = json.loads(urlfetch.fetch(github.USER_EMAILS_URL%access_token).content)
	for email in response:
		if email['primary']:
			logging.info(email['email'])
			user = User.get_by_key_name(email['email'])
	if not user:
		user = User(key_name=email['email'])
		user.put()
	response = json.loads(urlfetch.fetch(github.USER_URL%access_token).content)
	id, followers = response['login'], response['followers']
	ThirdPartyUser(key_name=GITHUB, parent=user, access_token=access_token, id=id, followers=followers).put()
开发者ID:ashray-velapanur,项目名称:moonlancer,代码行数:14,代码来源:auth.py

示例14: make_photo_dict

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
def make_photo_dict(photo, email):
    photo_dict = {}
    owner = User.get_by_key_name(photo.owner_email)
    photo_dict['image'] = photo.image_url
    photo_dict['owner_email'] = photo.owner_email
    photo_dict['owner_first_name'] = owner.first_name
    photo_dict['owner_last_name'] = owner.last_name
    photo_dict['num_votes'] = Vote.count(photo)
    photo_dict['num_comments'] = len(Comment.for_(photo))
    photo_dict['is_voted'] = Vote.is_voted(email, photo)
    photo_dict['profile_picture'] = owner.profile_picture
    return photo_dict
开发者ID:mschwalb,项目名称:photobout,代码行数:14,代码来源:util.py

示例15: get_user_or_letlogin

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import get_by_key_name [as 别名]
def get_user_or_letlogin(ctrl, dest_url='/'):
    from google.appengine.api import users
    guser = users.get_current_user()
    if not guser:
        ctrl.redirect(users.create_login_url(dest_url))
        return None

    user = User.get_by_key_name(guser.email())
    if not user:
        user = User(key_name=guser.email(), email=guser.email())
        user.put()
    return user
开发者ID:chihchun,项目名称:bebebe,代码行数:14,代码来源:auth.py


注:本文中的model.user.User.get_by_key_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。