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


Python Person.get方法代码示例

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


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

示例1: familytree_primitives_data

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
def familytree_primitives_data():
    filter_surnames = set(x for x in request.values.get('surname', '').lower().split(',') if x)

    # only show given individual
    single_person = request.values.get('single_person')
    if single_person:
        people = [Person.get(single_person)]
    else:
        people = sorted(Person.find(), key=lambda p: p.group_name)

    relatives_of = request.values.get('relatives_of')
    if relatives_of:
        central_person = Person.get(relatives_of)
        people = central_person.related_people

    # only find ancestors of given person
    ancestors, descendants = None, None
    ancestors_of = request.values.get('ancestors_of')
    if ancestors_of:
        central_person = Person.get(ancestors_of)
        ancestors = central_person.find_ancestors()

    descendants_of = request.values.get('descendants_of')
    if descendants_of:
        central_person = Person.get(descendants_of)
        descendants = central_person.find_descendants()

    if ancestors_of or descendants_of:
        people = set(list(ancestors or [])) | set(list(descendants or []))

    def _prepare_item(person):
        names_lowercase = (n.lower() for n in person.group_names)
        if filter_surnames:
            intersects = filter_surnames & set(names_lowercase)
            if not intersects:
                return

        # ethical reasons
        if person.death.year:
            tmpl = '{born} — {dead}'
        else:
            tmpl = '{born}'
        description = tmpl.format(born=person.birth.year_formatted or '?',
                                  dead=person.death.year_formatted or '?')
        return {
            'id': person.id,
            'title': person.name,
            'parents': [p.id for p in person.get_parents()],
            'spouses': [p.id for p in person.get_partners()],
            'description': description,
            'gender': person.gender,
        }
    prepared = (_prepare_item(p) for p in people)
    filtered = (p for p in prepared if p)
    return json.dumps(list(filtered))
开发者ID:daleathan,项目名称:wtfamily,代码行数:57,代码来源:web.py

示例2: post

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
    def post(self,key):
        user = User.get(key)
        person_key = user.people_singleton[0].key()
        person = Person.get(person_key)

        user.email = self.get_argument('email')
        user.corporate_email = self.get_argument('corporate_email')
        
        
        person.first_name = self.get_argument('first_name')
        person.last_name = self.get_argument('last_name')
        person.designation = self.get_argument('designation')
        person.company = self.get_argument('company')
        person.graduation_year = int(self.get_argument('graduation_year'))
        person.gender = self.get_argument('gender')
        person.t_shirt_size = self.get_argument('t_shirt_size')
        is_student = self.get_argument('is_student')
        if is_student == 'yes':
            person.is_student = True
        
        phone_count = int(self.get_argument('phone_count'))
        if phone_count:
            phones = []
            for phone in person.phones:
                str_key = str(phone.key())
                phone.number = self.get_argument(str_key)
                phones.append(phone)
            db.put(phones)
        
        user.put()
        person.put()
        self.redirect('/admin')
开发者ID:yesudeep,项目名称:old-milsalumni,代码行数:34,代码来源:admin.py

示例3: delete

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
  def delete(self):
    # 必須パラメータ取得
    person_id = self.request.get("id")
    if (not person_id):
      self.redirect(urls.APP_PERSON_URL)

    # Person取得
    person_obj = Person.get( person_id )
    if (not person_obj):
      self.redirect(urls.APP_PERSON_URL)

    # Personが所有する名言を取得する
    query = Meigen.all()
    query.filter( 'person = ', person_obj )
    meigens = query.fetch(limit = 1)

    if (meigens):
      # 名言が1つ以上あるから削除できません。メッセージを出す
      self.redirect(urls.APP_PERSON_URL)
      return

    # Person 削除
    person_obj.delete()

    # 発言者一覧へリダイレクト
    self.redirect(urls.APP_PERSON_URL)
开发者ID:sadao,项目名称:meigen-pedia,代码行数:28,代码来源:person.py

示例4: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
  def get(self):
    # 編集確認
    person_id = self.request.get("id")
    person_obj = ''
    if (person_id):
      person_obj = Person.get( person_id )

    # 所有しない発言者IDを指定された場合は一覧へリダイレクトする
    if person_obj and person_obj.owner != users.get_current_user():
      self.redirect(urls.APP_PERSON_URL)
      return

    # 所有する発言者を取得します
    query = Person.all()
    query.filter( 'owner = ', users.get_current_user() )
    query.order('-created_on')
    owned_persons = query.fetch(limit = 1000)

    # 所有する発言者の名言を取得する
    meigens = ''
    if person_obj:
      query = Meigen.all()
      query.filter( 'owner = ', users.get_current_user() )
      query.filter( 'person = ', person_obj )
      meigens = query.fetch(limit = 1000)

    # 画面を表示する
    Viewer.generate(Viewer(), self.response, TEMPLATE_PATH, { 'persons': owned_persons, 'current_person': person_obj, 'meigens': meigens } )
开发者ID:sadao,项目名称:meigen-pedia,代码行数:30,代码来源:person.py

示例5: post

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
 def post(self):
     person = Person.get(Person.qq == self.current_user)
     person.pnumber = self.get_argument("mobile")
     person.address = self.get_argument("address")
     person.others = self.get_argument("others")
     person.mdf_time = datetime.now()
     person.save()
     self.redirect("/")
开发者ID:yuejd,项目名称:class6,代码行数:10,代码来源:admin.py

示例6: post

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
 def post(self):
     qq = self.get_argument("qq")
     try:
         person = Person.get(Person.qq == qq)
         self.set_secure_cookie("qq", qq, expires_days = 1)
         person.login_times += 1
         person.save()
         self.redirect("/")
     except Person.DoesNotExist:
         log = "对不起,仅幻想6班QQ群用户可以登陆"
         self.render("login.html", message = log)
         LoginInfo.create(login_time = datetime.now(), qq = qq)
开发者ID:yuejd,项目名称:class6,代码行数:14,代码来源:login.py

示例7: insert_or_update

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
  def insert_or_update(self):
    # パラメータ取得
    person_name = self.request.get("name")
    person_description = self.request.get("description")
    is_lock = self.request.get("is_lock")

    # パラメタが不正なときは一覧画面へリダイレクトする
    if (person_name == '' or is_lock == ''):
      self.redirect(urls.APP_PERSON_URL)
      return

    # is_lock を Boolean型にする
    if (is_lock == 'True'):
      is_lock = True
    else:
      is_lock = False

    # TwitterID
    twitter_id = self.request.get("twitter_id")

    # 更新
    if self.request.get("id"):
      # Person取得
      person_obj = Person.get( self.request.get("id") )
      if (not person_obj):
        self.redirect(urls.APP_PERSON_URL)

      # Personの所有する名言を取得
      query = Meigen.all()
      query.filter( 'person = ', person_obj )
      owned_meigens = query.fetch(limit = 1)

      # 名言が1つ以上所属している場合は発言者名を変更できない!!とエラーであることを知らせる
      if person_obj.name != person_name and owned_meigens:
        self.redirect(urls.APP_PERSON_URL)
      # Person 削除
      else:
      	person_obj.delete()

    # Person 登録
    person_obj = Person.get_or_insert(
                   person_name,
                   owner = users.get_current_user(),
                   name = person_name,
                   description = person_description,
                   twitter_id = twitter_id,
                   is_lock = is_lock )

    # 発言者一覧へリダイレクト
    self.redirect(urls.APP_PERSON_URL)
开发者ID:sadao,项目名称:meigen-pedia,代码行数:52,代码来源:person.py

示例8: delete

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
def delete(id):
    try:
        person = Person.get(Person.id == id)
    except Person.DoesNotExist:
        abort(404)

    if request.method == 'POST':
        person.delete_instance()

        if request.is_xhr:
            return jsonify(success=True, person=person.serialize())
        else:
            return redirect(url_for('index'))

    return render_template('delete.html', person=person)
开发者ID:auswm85,项目名称:peoplecrudsample,代码行数:17,代码来源:app.py

示例9: individual

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
  def individual(self, person_id):
    # 発言者取得
    person_obj = Person.get(person_id)
    message = ''
    if (not person_obj):
      message = '指定された発言者は登録されていません'

    # 発言者の名言を取得
    query = Meigen.all().order('-created_on')
    query.filter( 'person = ', person_obj )
    meigens_of_person = query.fetch( limit = 1000 )

    Viewer.generate(Viewer(), self.response, INDIVIDUAL_TEMPLATE_PATH, 
    { 'current_person': person_obj,
      'current_meigens': meigens_of_person,
      'persons': Person.all().order('-created_on'),
      'message': message })
开发者ID:sadao,项目名称:meigen-pedia,代码行数:19,代码来源:person.py

示例10: edit

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
def edit(id):
    try:
        person = Person.get(Person.id == id)
    except Person.DoesNotExist:
        abort(404)

    form = PersonForm(request.form, person)

    if request.method == "POST" and form.validate():
        person.firstname = form.firstname.data
        person.lastname = form.lastname.data
        person.birthday = form.birthday.data
        person.zipcode = form.zipcode.data
        person.save()

        return redirect(url_for('index'))

    return render_template('edit.html', form=form, person=person)
开发者ID:auswm85,项目名称:peoplecrudsample,代码行数:20,代码来源:app.py

示例11: destroy

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
 def destroy(self):
   person = Person.get(db.Key(encoded=self.request.get("key")))
   if person:
     person.delete()
开发者ID:dohoang1102,项目名称:a2,代码行数:6,代码来源:person.py

示例12: tx

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
 def tx(key, login):
   person = Person.get(db.Key(encoded=key))
   person.login = login
   person.put()
开发者ID:dohoang1102,项目名称:a2,代码行数:6,代码来源:person.py

示例13: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
 def get(self):
   person = Person.get(db.Key(encoded=self.request["key"]))
   self.respond_with(person.to_json())
开发者ID:dohoang1102,项目名称:a2,代码行数:5,代码来源:person.py

示例14: person_detail

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
def person_detail(obj_id):
    obj = Person.get(obj_id)
    if not obj:
        abort(404)
    return render_template('person_detail.html', obj=obj)
开发者ID:daleathan,项目名称:wtfamily,代码行数:7,代码来源:web.py

示例15: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get [as 别名]
 def get(self):
     self.render('edit.html', 
                 person = Person.get(Person.qq == self.current_user))
开发者ID:yuejd,项目名称:class6,代码行数:5,代码来源:admin.py


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