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


Python Person.filter方法代码示例

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


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

示例1: cv

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import filter [as 别名]
def cv(user):
    # quick check to make sure the user actually exists
    resp = fluid.get('/users/%s' % user)
    if resp.status_code == 404:
        abort(404)
    person_rpc = Person.filter('fluiddb/users/username="%s"', user, async=True)
    # check for person's picture
    #logging.debug('Checking for %s/picture at %s' % (user, person.picture))
    #h = httplib2.Http()
    #head, cont = h.request(person.picture, 'HEAD')
    #if head['status'] == '200':
    #    person.has_pic = True
    #    logging.debug('%s/picture exists' % user)
    #else:
    #    person.has_pic = False
    #    logging.debug('%s/picture does not exist. Returned %s status' % (
    #        user, head['status']))
    # find user's jobs
    work_rpc = Work.filter('has %s/employer', user, async=True)
    # find user's schools
    school_rpc = Education.filter('has %s/attended', user, async=True)
    # find user's publications
    #publications = fluid_filter('has %s/publication' % user)
    #publications = [Publication(uid, user) for uid in publications]
    publications = []
    # find user's skills associated with o'reilly books
    oskill_rpc = OReillySkill.filter(
            'has %s/skill and has %%s/title' % user, 'oreilly.com', async=True)

    resp = fluid.result(person_rpc)
    logging.info('Person filter for %s returned %d' % (user, resp.status_code))
    if resp.status_code == 200 and resp.content['results']['id']:
        [(uid, tags)] = resp.content['results']['id'].items()
        person = Person(uid, user, tags)
    else:
        abort(404)

    resp = fluid.result(work_rpc)
    logging.info('Work filter for %s returned %d' % (user, resp.status_code))
    if resp.status_code == 200 and resp.content['results']['id']:
        resp = resp.content['results']['id']
        jobs = Work.from_response(user, resp)
    else:
        #FIXME need better error handling
        jobs = []

    resp = fluid.result(school_rpc)
    logging.info('School filter for %s returned %d' % (user, resp.status_code))
    if resp.status_code == 200 and resp.content['results']['id']:
        resp = resp.content['results']['id']
        schools = Education.from_response(user, resp)
    else:
        schools = []

    resp = fluid.result(oskill_rpc)
    logging.info('Skill filter for %s returned %d' % (user, resp.status_code))
    if resp.status_code == 200 and resp.content['results']['id']:
        resp = resp.content['results']['id']
        oskills = OReillySkill.from_response(resp)
    else:
        oskills = []

    return render_template('cv.html', person=person, jobs=jobs,
                           schools=schools, publications=publications,
                           oskills=oskills,
                           current_date=datetime.now().date())
开发者ID:gridaphobe,项目名称:fluid-cv,代码行数:68,代码来源:__init__.py


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