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


Python Person.query方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
 def get(self):
     people_keys = Person.query().fetch(keys_only=True)
     for person_key in people_keys:
         self.response.write('kind: %s <br>'% person_key.kind())
         self.response.write('id: %s <br>'% person_key.id())
         self.response.write('urlsafe: %s <br>'% person_key.urlsafe())
         self.response.write('<hr>')
开发者ID:Eforcers,项目名称:google-dev-courses,代码行数:9,代码来源:views.py

示例2: dispatch_request

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
	def dispatch_request(self):
		Usr = users.get_current_user()
		if Usr.email() == '[email protected]' or Usr.email() == '[email protected]':
			parties = Party.query()
			persons = Person.query()			
			return render_template('admin_list.html',parties=parties,persons=persons, Party=Party,Person=Person)
		else:
			flash(u'Sorry, no admission!')
			return redirect(url_for('rsvp'))
开发者ID:mad-magic,项目名称:src,代码行数:11,代码来源:views_all.py

示例3: list_persons

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
 def list_persons(self, request):
     authorise(request.person, request.token)
     persons = Person.query(Person.parentId==request.id).fetch()
     # meetings = Meeting.query().fetch()
     res = PersonsCollection()
     for person in persons:
         msg = PersonMsg(name=person.name, id=person.key.id(), email=person.email, parentId=request.id)
         res.items.append(msg)
     return res
开发者ID:ShyAlon,项目名称:herex,代码行数:11,代码来源:meetingsApi.py

示例4: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
 def get(self):
   user = users.get_current_user()
   
   # Get all users that have a photo
   qry = Person.query(Person.has_picture == True).fetch(100)
   #Shuffle the list around to make it different every time
   shuffle(qry)
   template_values = {'user': user, 'people': qry}
   template = jinja_environment.get_template('html/photomap.html')
   self.response.out.write(template.render(template_values))
开发者ID:origamize,项目名称:RPI-Directory,代码行数:12,代码来源:photomap.py

示例5: post

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
 def post(self):
   user = users.get_current_user()
   if user:
     if user.email() in admins:
       #Allow picture replacement for admins
       person = Person.get_by_id(self.request.get('rcsid'))
     else:
       person = Person.query(Person.linked_account == user).get()
     if person:
       person.picture = images.resize(self.request.get('file'), 150, 150)
       person.put()
       logging.debug('Uploaded Picture: ' + person.rcsid)
       return
开发者ID:mdznr,项目名称:RPI-Directory,代码行数:15,代码来源:picture.py

示例6: init

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
def init():
    ndb.delete_multi(
        Person.query().fetch(keys_only=True)
    )

    Person(
        name = "Test User",
        setting_id = "default",
        trigger_level = "close",
        mobile = TWILIO["TEST_MOBILE"],
        last_level = "very_low"
    ).put()

    makedata()
开发者ID:fergusg,项目名称:oxfloodwatch,代码行数:16,代码来源:main.py

示例7: dispatch_request

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
	def dispatch_request(self, party_id):
		Usr = users.get_current_user()
		if Usr.email() == '[email protected]gmail.com' or Usr.email() == '[email protected]':
			party = Party.get_by_id(party_id)
			persons = Person.query(Person.party == ("%s" % party.key.id()) )
			if request.method == "POST":
				for ps in persons:
					ps.key.delete()
				party.key.delete()
				flash(u'Party and persons %s successfully deleted.' % party_id, 'success')
				return redirect(url_for('admin'))
			return redirect(url_for('admin'))
		else:
			flash(u'Sorry, no admission!')
			return redirect(url_for('index'))
开发者ID:mad-magic,项目名称:src,代码行数:17,代码来源:admin_delete_party.py

示例8: delete

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
    def delete(self, request):
        authorise(request.person, request.token)
        try:
            meeting = Meeting.get_by_id(request.id)
            if meeting.originator == request.person:
                persons = Person.query(Person.parentId==request.id).fetch()
                for person in persons:
                    roles = Role.query(Role.parentId==person.key.id()).fetch()
                    for role in roles:
                        role.key.delete()
                    person.key.delete()
                meeting.key.delete()
            else: # just remove the person from the meeting
                persons = Person.query(Person.parentId==request.id).fetch()
                for person in persons:
                    if(person.email == request.person):
                        roles = Role.query(Role.parentId==person.key.id()).fetch()
                        for role in roles:
                            role.key.delete()
                        person.key.delete()

            return message_types.VoidMessage()
        except (IndexError, TypeError):
            raise endpoints.NotFoundException('Role %s not found.' % (request.id,))
开发者ID:ShyAlon,项目名称:herex,代码行数:26,代码来源:meetingsApi.py

示例9: post

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
 def post(self):
   user = users.get_current_user()
   if user:
     if user.email() in admins:
       #Allow picture replacement for admins
       person = Person.get_by_id(self.request.get('rcsid'))
     else:
       person = Person.query(Person.linked_account == user).get()
     if person:
       person.picture = images.resize(self.request.get('file'), width=200, height=200,
                                      correct_orientation=True)                 
       person.put()
       logging.info('Uploaded Picture: ' + person.rcsid)
       return
   else:
     logging.info('Not Logged in to Modify Image')
开发者ID:origamize,项目名称:RPI-Directory,代码行数:18,代码来源:picture.py

示例10: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
  def get(self):
    # Check if signed in
    user = users.get_current_user()
    rcsid_claim = self.request.get("rcsid_claim", None)
    activation_code = self.request.get("activation", None)
    person = Person.query(Person.linked_account == user).get()
    login_url = users.create_login_url(self.request.uri)

    if user and person:
      self.redirect('/detail/' + person.rcsid)
      return
    elif rcsid_claim:
      if not user:
        self.redirect(users.create_login_url(self.request.uri))
        return
      #Generate code and send email
      code = str(random.randrange(sys.maxint))
      item = {'code': code, 'rcsid': rcsid_claim}
      if not memcache.add(str(user.user_id()), item, 86400):
        message = 'Already sent activation, please check your email and your spam folder.'
      else:
        person = Person.get_by_id(rcsid_claim)
        if person:
          result = send_activation_email(person, user, code)
          logging.info('Sent email to link %s and %s, result: %s' % (user.email(), person.rcsid, str(result)))
          message = 'Sent activation email to: %s, please check that email.' % (person.email)
        else:
          message = 'Invalid RCS ID: %s...' % (rcsid_claim)
    elif user and activation_code:
      #Check if already exisiting code
      item = memcache.get(str(user.user_id()))
      if item is not None and item['code'] == activation_code:
        person = Person.get_by_id(item['rcsid'])
        person.linked_account = user
        person.put()
        self.redirect('/detail/' + person.rcsid)
        return
    else:
      #Not signed in, offer instructions
      message = None

    template_values = {"active": "dashboard", 
                       "message": message,
                       "login_url": login_url}
    template = jinja_environment.get_template('html/activate.html')
    self.response.out.write(template.render(template_values))
开发者ID:origamize,项目名称:RPI-Directory,代码行数:48,代码来源:dashboard.py

示例11: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
 def get(self, rcs_id):
   user = users.get_current_user()
   enabled_user = None
   person = Person.get_by_id(rcs_id)
   if person and person.picture:
     img = 'http://rpidirectory.appspot.com/picture/%s' % (rcs_id)
   else:
     img = 'https://dl.dropbox.com/u/1253608/370556590677.png'
   if user:
     enabled_user = Person.query(Person.linked_account == user).get()
   
   template_values = {"active": "dashboard",
                      "rcs_id": rcs_id,
                      "person": person,
                      "user": user,
                      "enabled_user": enabled_user,
                      "img": img}
   template = jinja_environment.get_template('html/detail.html')
   self.response.out.write(template.render(template_values))
开发者ID:origamize,项目名称:RPI-Directory,代码行数:21,代码来源:detail.py

示例12: processMeeting

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
 def processMeeting(self, meeting):
     logging.info('Processing {}'.format(meeting.title))
     participants = Person.query(Person.parentId == meeting.key.id()).fetch()
     for person in participants:
         self.processParticipant(person, meeting)
开发者ID:ShyAlon,项目名称:herex,代码行数:7,代码来源:main.py

示例13: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
    def get(self):
        ts = getTimeseries()
        if not ts:
            m = "sendalerts abort - no timeseries"
            logging.info(m)
            return m

        # Filter temp=null
        ts = [ t for t in ts if t[2] is not None]
        if len(ts) == 0:
            m = "sendalerts abort - no readings"
            logging.info(m)
            return m

        ts = [[t[0], adjust_height(t[1], t[2]), t[2]] for t in ts]

        (current_time, current_level, current_temp) = ts[0]

        if current_temp is None:
            m = "sendalerts abort - current temp unknown"
            logging.info(m)
            return m

        # Try to detect spikes - if this level is 50cm higher than avg of the prev 3 readings, abort
        recent_levels = [float(x[1]) for x in ts[1:4]]
        n_recent_levels = max(len(recent_levels),1)

        avg_recent = sum(recent_levels)/n_recent_levels
        if abs(current_level - avg_recent) > 50:
            m = "sendalerts abort - spike?"
            logging.info(m)
            return m

        ret = []

        for p in Person.query():
            s = Settings[p.setting_id]
            levels = s["levels"]
            (level, delta) = self.getLevel(s["normal"], levels, current_level)
#            (level, delta) = ("extreme", 40)

            level_names = [f["name"] for f in levels]
            trigger_idx = level_names.index(p.trigger_level)
            level_idx = level_names.index(level)
            last_level_idx = level_names.index(p.last_level)

            alert = last_level_idx != level_idx

            # alert = alert and ((level > p.trigger_level) or (level < p.trigger_level))

            msg = {
                "name": p.name,
                "phone": p.mobile,
                "enabled": getattr(p, "enabled", False),
                "normal_level": s["normal"],
                "delta": delta,
                "level": level,
                "level_idx": level_idx,
                "last_level": p.last_level,
                "last_level_idx": last_level_idx,
                "trigger_idx": trigger_idx,
                "alert": alert
            }

            alert = False

            # msg = "%s: %s enabled:%s norm:%s delta:%s level:(%s, %s) last:(%s, %s) trigger:%s alert:%s" % (
            #     p.name, p.mobile, s["normal"], delta, level, level_idx, p.last_level, last_level_idx, trigger_idx, alert)
            ret.append(msg)
            logging.info(json.dumps(msg, indent=4))

            if alert:
                p.last_level = level
                p.put()
                m = "Dear {pname}, the level at {sname} is now {level} ({delta}cm)".format(
                    pname=p.name,
                    sname=s["name"],
                    level=levels[level_idx]["desc"],
                    delta=delta
                )
                logging.info("Sending %s to %s" % (m, p.mobile))
                try:
                    sendMessage(p.mobile, m)
                except Exception as e:
                    logging.error(e)

        return json.dumps(ret, indent=4)
开发者ID:fergusg,项目名称:oxfloodwatch,代码行数:89,代码来源:main.py

示例14: post

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
    def post(self):
       user_id = self.request.get('user_id')
       event_id = self.request.get('event_id')
       event = Event.get_by_id(int(event_id))
       operation = self.request.get('operation')
       if (operation == "load"):
          if (user_id == event.userId):

             template_values = {
                 'event': event
             }

             template = JINJA_ENVIRONMENT.get_template('event_update.html')
             self.response.write(template.render(template_values))
          else:
             template = JINJA_ENVIRONMENT.get_template('index.html')
             self.response.write(template.render())
       elif (operation == "people_for_event"):
            user_id = self.request.get('user_id')
            event_id = int(self.request.get('event_id'))
            event = Event.get_by_id(event_id)

            event_people = []
            for person_id in event.event_people:
                person = Person.get_by_id(int(person_id))
                event_people.append({"person_id": person_id, "display_name": person.display_name,
                                   "image_url": person.image_url })
            event_people_set = set(event.event_people)

            person_keys = (Person.query(Person.userId == user_id).fetch(keys_only=True))
            all_people = []
            for key in person_keys:
                all_people.append(key.id())
            clean_people = [x for x in all_people if x not in event_people_set]
            all_people = []
            for person_id in clean_people:
                person = Person.get_by_id(int(person_id))
                all_people.append({"person_id": person_id, "display_name": person.display_name,
                                   "image_url": person.image_url })

            event_sharing_set = set(event.event_sharing)
            my_key = Person.query(Person.plus_id == user_id).get(keys_only=True)
            event_sharing_set.add(my_key.id())
            available_sharing = []
            for key in person_keys:
                available_sharing.append(key.id())
            clean_sharing = [x for x in available_sharing if x not in event_sharing_set]
            available_sharing = []
            for person_id in clean_sharing:
                person = Person.get_by_id(int(person_id))
                available_sharing.append({"person_id": person_id, "display_name": person.display_name,
                                           "image_url": person.image_url, "email": person.email })
            event_sharing = []
            for person_id in event.event_sharing:
                person = Person.get_by_id(int(person_id))
                event_sharing.append({"person_id": person_id, "display_name": person.display_name,
                                        "image_url": person.image_url, "email": person.email })

            ret_data = { "all_people": all_people, "event_people": event_people, 
                         "available_sharing": available_sharing, "event_sharing": event_sharing }

            self.response.write(json.dumps(ret_data))
       elif (operation == "photos_for_event"):
            user_id = self.request.get('user_id')
            event_id = self.request.get('event_id')
            event = Event.get_by_id(int(event_id))

            photo_keys = (Photo.query(Photo.userId == user_id).fetch(keys_only=True))
            event_photos_set = set(event.event_photos)

            event_photos = []
            for photo_id in event.event_photos:
                photo = Photo.get_by_id(int(photo_id))
                event_photos.append({"photo_id": photo_id, "drive_id": photo.drive_id, 
                                       "thumbnailLink": photo.thumbnailLink })

            all_photos = []
            for photo_key in photo_keys:
                all_photos.append(photo_key.id())
            clean_photos = [x for x in all_photos if x not in event_photos_set]

            all_photos = []
            for photo_id in clean_photos:
                photo = Photo.get_by_id(int(photo_id))
                all_photos.append({"photo_id": photo_id, "drive_id": photo.drive_id, 
                                     "thumbnailLink": photo.thumbnailLink })
            ret_data = { "all_photos": all_photos, "event_photos": event_photos }

            self.response.write(json.dumps(ret_data))
       elif (operation == "change_people"):
            person_id = int(self.request.get('person_id'))
            change_to = self.request.get('change_to')
            if (change_to == "connected"):
                event.event_people.append(person_id)
                event.put()
            else:
               if person_id in event.event_people:
                   event.event_people.remove(person_id)
                   event.put()
               else:
#.........这里部分代码省略.........
开发者ID:ripplesphere,项目名称:sample_code,代码行数:103,代码来源:event_update.py

示例15: get

# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import query [as 别名]
 def get(self):
     persons = Person.query().fetch()
     params = {"persons": persons}
     return self.render_template("main.html", params=params)
开发者ID:smartninja,项目名称:scrapebook,代码行数:6,代码来源:main.py


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