本文整理汇总了Python中models.Person.get_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Person.get_by_id方法的具体用法?Python Person.get_by_id怎么用?Python Person.get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Person
的用法示例。
在下文中一共展示了Person.get_by_id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def get(self):
person = Person.get_by_id(self.request.get('rcsid'))
if person:
self.response.headers['Content-Type'] = 'image/png'
self.response.out.write(person.picture)
else:
self.error(404)
示例2: dispatch_request
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def dispatch_request(self, person_id):
Usr = users.get_current_user()
if Usr.email() == '[email protected]' or Usr.email() == '[email protected]':
person = Person.get_by_id(person_id)
form = PersonForm(obj=person.key.id())
form.title.data = person.title
form.first.data = person.first
form.last.data = person.last
form.rsvp.data = person.rsvp
form.food.data = person.food
form.party.data = person.party
if request.method == "POST" and form.validate_on_submit():
person.title = form.data.get('title')
person.first = form.data.get('first')
person.last = form.data.get('last')
person.rsvp = form.data.get('rsvp')
person.food = form.data.get('food')
person.party = form.data.get('party')
person.put()
flash(u'Person %s successfully saved.' % person_id, 'success')
return redirect(url_for('admin'))
return render_template('edit_person.html', person=person, form=form)
else:
flash(u'Sorry, no admission!')
return redirect(url_for('index'))
示例3: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def get(self, rcsid):
person = Person.get_by_id(rcsid)
if person and person.has_picture:
self.response.headers['Content-Type'] = 'image/png'
self.response.out.write(person.picture)
else:
self.response.headers['Content-Type'] = 'image/png'
self.response.out.write(base64.b64decode(unknown_image))
示例4: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [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))
示例5: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def get(self, rcs_id):
logging.error('RCSID: ' + rcs_id)
user = users.get_current_user()
template_values = {"active": "dashboard",
"rcs_id": rcs_id,
"person": Person.get_by_id(rcs_id),
"user": user}
path = os.path.join(os.path.dirname(__file__), 'html/detail.html')
self.response.out.write(template.render(path, template_values))
示例6: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def get(self,person_id):
person = Person.get_by_id(int(person_id))
variables = {
'person': person
}
template = JINJA_ENVIRONMENT.get_template('person_display.html')
self.response.write(template.render(variables))
示例7: dispatch_request
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def dispatch_request(self, person_id, dd):
Usr = users.get_current_user()
if Usr.email() == '[email protected]' or Usr.email() == '[email protected]':
person = Person.get_by_id(person_id)
if request.method == "POST":
person.rsvp = dd
person.put()
return redirect(url_for('admin'))
else:
flash(u'Sorry, no admission!')
return redirect(url_for('index'))
示例8: delete
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def delete(self, request):
authorise(request.person, request.token)
try:
person = Person.get_by_id(request.id)
roles = Role.query(Role.parentId==request.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,))
示例9: dispatch_request
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def dispatch_request(self, person_id):
Usr = users.get_current_user()
if Usr.email() == '[email protected]' or Usr.email() == '[email protected]':
person = Person.get_by_id(person_id)
if request.method == "POST":
person.key.delete()
flash(u'Person %s successfully deleted.' % person_id, 'success')
return redirect(url_for('admin'))
return redirect(url_for('admin'))
else:
flash(u'Sorry, no admission!')
return redirect(url_for('index'))
示例10: post
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [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
示例11: get_person_by_email
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def get_person_by_email(email):
"""Helper method to get the Person object corresponding to the given email.
Creates a new Person object if one didn't exist already.
"""
person = Person.get_by_id(email, parent=get_parent_key_from_email(email))
logging.info("person = " + str(person))
if not person:
logging.info("Failed to find person by id, creating new user")
# DONE: Create a new person with the id = email and parent of get_parent_key_from_email
person = Person(parent=get_parent_key_from_email(email),
id=email)
person.put()
return person
示例12: putResult
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def putResult(d):
if 'rcsid' not in d:
return
key = d['rcsid']
prev_person = Person.get_by_id(key)
if prev_person:
logging.info("Updating %s", key)
prev_person.update(d)
prev_person.put()
search.Index(name=_INDEX_NAME).put(createDocument(prev_person))
else:
logging.info("New %s", key)
person = Person.buildPerson(d)
person.put()
search.Index(name=_INDEX_NAME).put(createDocument(person))
示例13: post
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [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')
示例14: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [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))
示例15: dispatch_request
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import get_by_id [as 别名]
def dispatch_request(self, cc):
party = Party.query(Party.code == cc).get()
if not party:
return render_template('404.html')
if request.method == "POST":
p_d = request.args.get('p', '')
ps = Person.get_by_id(int(p_d))
r_d = request.args.get('r', '')
f_d = request.args.get('f', '')
try:
if r_d:
ps.rsvp = r_d
if f_d:
ps.food = f_d
ps.put()
except CapabilityDisabledError:
flash(u'App Engine Datastore is currently in read-only mode.', 'info')
return redirect(url_for('code', cc=cc))
return redirect(url_for('code',cc=cc))
else:
persons = Person.query(Person.party == ("%s" % party.key.id()) )
return render_template('code.html', party=party, persons=persons)