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


Python User.name方法代码示例

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


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

示例1: friends

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
 def friends(self, user_id):
     if not (self.access_token and self.access_token_secret):
         self._authorize()
     page = 1
     while True:
         self.logger.info('On page %s of the friends of user %s' % (page, user_id))
         session = OAuth1Session(
             consumer_key=self.key,
             consumer_secret=self.secret,
             access_token=self.access_token,
             access_token_secret=self.access_token_secret,
         )
         endpoint = 'https://www.goodreads.com/friend/user/%s' % (user_id)
         params = {'format': 'xml', 'key': self.key, 'page': page}
         r = session.get(endpoint, params=params)
         if r.status_code != 200:
             raise GoodReadsError(r.text)
         soup = BeautifulSoup(r.content, 'xml')
         end = int(soup.GoodreadsResponse.friends['end'])
         total = int(soup.GoodreadsResponse.friends['total'])
         users = soup.GoodreadsResponse.friends
         for user_tag in users.find_all('user'):
             user = User(int(user_tag.id.text))
             user.name = user_tag.find('name').text
             user.link = user_tag.link.text
             user.friends_count = int(user_tag.friends_count.text)
             user.reviews_count = int(user_tag.reviews_count.text)
             try:
                 user.created_at = date_parser.parse(user_tag.created_at.text)
             except:
                 pass
             yield user
         if end >= total:
             break
         page += 1
开发者ID:linron84,项目名称:pygoodreads,代码行数:37,代码来源:client.py

示例2: create_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
def create_user(name='', fbid='', group=''):
  '''Creates a new user

  Uses facebook for authentication
  '''
  # TODO: check to make sure user is not already_taken
  #TODO: check fb, get fb token.
  #TODO: check to make sure block id is good

  assert isinstance(name, basestring), 'Expected name to be string'
  now = datetime.datetime.now()
  # Users without names should have a nickname.

  group_ref = get_group('group_name')

  # Create a new user
  new_user = User()

  new_user.fbid         = fbid,
  new_user.name         = name,
  new_user.usename      = name,
  new_user.group        = groupid,
  new_user.blocks       = blocks,
  new_user.date_created = now,
  user.date_modified    = now
开发者ID:mvanveen,项目名称:unblockr,代码行数:27,代码来源:controller.py

示例3: oauth_authorized

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
def oauth_authorized(resp):
    """Called after authorization.  After this function finished handling,
    the OAuth information is removed from the session again.  When this
    happened, the tokengetter from above is used to retrieve the oauth
    token and secret.

    Because the remote application could have re-authorized the application
    it is necessary to update the values in the database.

    If the application redirected back after denying, the response passed
    to the function will be `None`.  Otherwise a dictionary with the values
    the application submitted.  Note that Twitter itself does not really
    redirect back unless the user clicks on the application name.
    """
    next_url = request.args.get('next') or url_for('index')
    if resp is None:
        #TODO: show friendly message
        #flash(u'You denied the request to sign in.')
        return redirect(next_url)

    screen_name = resp['screen_name']
    oauth_token = resp['oauth_token']
    oauth_token_secret = resp['oauth_token_secret']
    
    user = User.select_by_screen_name(screen_name)
    if not user:
        app.logger.debug('User not found on database. Using the Twitter API')
        auth = tweepy.OAuthHandler(config.CONSUMER_KEY, config.CONSUMER_SECRET)
        auth.set_access_token(oauth_token, oauth_token_secret)
        api = tweepy.API(auth)
        twitter_user = api.get_user(screen_name=screen_name)
        user = User()
        user.id = twitter_user.id
        user.screen_name = twitter_user.screen_name
        user.blocked = 'N'
        user.name = twitter_user.name
        user.description = twitter_user.description
        user.created_at = twitter_user.created_at
        user.friends_count = twitter_user.friends_count
        user.followers_count = twitter_user.followers_count
        user.statuses_count = twitter_user.statuses_count
        user.profile_image_url = twitter_user.profile_image_url
        user.lang = twitter_user.lang
        user.location = twitter_user.location
        user.oauth_token = oauth_token
        user.oauth_token_secret = oauth_token_secret
        User.add(user)
    else:
        user.oauth_token = oauth_token
        user.oauth_token_secret = oauth_token_secret

    flask.session['screen_name'] = resp['screen_name']
    flask.session['oauth_token'] = resp['oauth_token']
    flask.session['oauth_token_secret'] = resp['oauth_token_secret']
    
    commit()
    
    return flask.redirect(next_url)
开发者ID:panisson,项目名称:whatshot,代码行数:60,代码来源:app.py

示例4: _create_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
 def _create_user(self):
     user_name = "NEW USER"
     user = User(None, user_name, moderator=False)
     self.orm.add(user)
     self.orm.commit()
     user.name = "Anonymous %d" % user.user_id
     self.orm.commit()
     self.next_ = "/user/%d" % user.user_id
     return user
开发者ID:ianmackinnon,项目名称:mango,代码行数:11,代码来源:auth.py

示例5: user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
 def user(self, user_id):
     endpoint = 'https://www.goodreads.com/user/show/%s.xml' % (user_id)
     params = {'key': self.key}
     r = requests.get(endpoint, params=params)
     if r.status_code != 200:
         raise GoodReadsError(r.text)
     soup = BeautifulSoup(r.content, 'xml')
     user_tag = soup.user
     user = User(int(user_tag.id.text))
     user.name = user_tag.find('name').text
     user.link = user_tag.link.text
     user.friends_count = int(user_tag.friends_count.text)
     user.reviews_count = int(user_tag.reviews_count.text)
     return user
开发者ID:linron84,项目名称:pygoodreads,代码行数:16,代码来源:client.py

示例6: CustomDecoder

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
def CustomDecoder(dic):
	if dic.has_key('login'):
		user = User(dic['login'],dic['p'])
		user.name=dic['name']
		user.logged=dic['logged']
		return user
	if dic.has_key('org'):
		repo = Repository(dic['org'],dic['name'])
		repo.directory=dic['directory']
		repo.json_exists=dic['json_exists']
		repo.exists=dic['exists']
		repo.content=dic['content']
		repo.file_name=dic['file_name']
		return repo
	else:
		print "Error while decoding object, unknown object: ",dic
开发者ID:SOM-Research,项目名称:graph-github,代码行数:18,代码来源:server.py

示例7: register_user

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
	def register_user(self, **kwargs):
		"""
		Register a new user in the database. Either nick or email attributes is required.
		"""
		assert("nick" in kwargs or "email" in kwargs)

		session = db.Session()

		group = session.query(Group).filter(Group.name == USERS_GROUP).first()
		if group is None:
			group = Group(name=USERS_GROUP, desc="Users")
			session.add(group)

		user = User(**kwargs)
		if user.name is None:
			user.name = user.nick or user.email
		user.groups += [group]

		session.add(user)
		session.commit()
		return user
开发者ID:chris-zen,项目名称:phd-thesis,代码行数:23,代码来源:server.py

示例8: create_person

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
def create_person(user):
    name = request.forms.get("name")
    email = request.forms.get("email")
    serial = request.forms.get("serial")
    if not any([name, email, serial]):
        return redirect(settings.ADMIN_PATH)

    try:
        person = User.get(email=email)
    except:
        person = User()
        person.email = email
    person.name = name
    person.serial = serial
    person.is_active = True

    try:
        person.save()
    except IntegrityError:
        return redirect(settings.ADMIN_PATH)

    return redirect("{0}/{1}".format(settings.ADMIN_PATH, person.id))
开发者ID:TeachBoost,项目名称:ansible,代码行数:24,代码来源:admin.py

示例9: _create_fixture_users

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
    def _create_fixture_users(self, config):
        ''' Create user fixtures. '''

        session = app.database.get_session(self._db)
        hash_algorithm = config.get('password_hash', 'algorithm')

        try:
            hash_rounds = int(config.get('password_hash', 'rounds'))
        except:
            raise ValueError('Configuration value password_hash.rounds must' \
                             ' be an integer: %s' % rounds)

        admin = User('admin')
        admin.agency = 'QuickPin'
        admin.name = 'Administrator'
        admin.is_admin = True
        admin.password_hash = model.user.hash_password(
            'MemexPass1',
            hash_algorithm,
            hash_rounds
        )
        session.add(admin)
        session.commit()
开发者ID:pombredanne,项目名称:quickpin,代码行数:25,代码来源:database.py

示例10: climbers

# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import name [as 别名]
 def climbers(self, summit_id):
     climbers = []
     sql = """SELECT
                 year,
                 month,
                 day,
                 comment,
                 users.id,
                 users.name,
                 users.preview
             FROM users LEFT JOIN climbs ON climbs.user_id=users.id
             LEFT JOIN summits ON climbs.summit_id=summits.id
             WHERE climbs.summit_id=%s ORDER BY year, month, day;"""
     with self.get_cursor() as cur:
         cur.execute(sql, (summit_id, ))
         for row in cur:
             u = User()
             u.id = row['id']
             u.name = row['name']
             u.preview = row['preview']
             climbers.append(
                 {'user': u, 'date': InexactDate.fromdict(row),
                  'comment': row['comment']})
     return climbers
开发者ID:binrush,项目名称:thousands,代码行数:26,代码来源:dao.py


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