本文整理汇总了Python中models.Person.gql方法的典型用法代码示例。如果您正苦于以下问题:Python Person.gql方法的具体用法?Python Person.gql怎么用?Python Person.gql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Person
的用法示例。
在下文中一共展示了Person.gql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_people
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import gql [as 别名]
def add_people(self, user):
# Add 10 People
people = [
'Nelson Mandella',
'the Queen of England',
'the Pope',
'President Obama',
'President Obama',
'Richard Branson',
'Bill Gates',
'Warren Buffet',
'Bon Jovi',
'Jennifer Aniston'
]
self.response.out.write('<hr/>Adding people to meet<hr/>')
# Get all list items for the current user
query = UserListItems.gql('WHERE user = :user', user=user)
user_list_items = query.get()
if user_list_items is None:
user_list_items = UserListItems(user=user)
for name in people:
# Add Person Entity
query = Person.gql('WHERE title=:name', name=name)
person = query.get()
if person:
self.response.out.write('Found %s in database<br/>' % person)
if not person:
person = Person()
person.title = name
person.put()
self.response.out.write('Added %s<br/>' % person)
# Update the list of items the user has
if person.key() not in user_list_items.list_items:
user_list_items.list_items.append(person.key())
self.response.out.write('Added %s to %s<br/>' % (person.key().to_path(), user_list_items.list_items))
# Add the specifics of the user list item linkage
user_list_item = UserListItem()
user_list_item.user = user
user_list_item.list_item = person
one_year = datetime.timedelta(days=365)
today = datetime.datetime.today()
user_list_item.date_due = today + one_year
user_list_item.put()
ListItemCounter.increment(user_list_item)
self.response.out.write('------------------------------------<br/>')
# Save the linkages from list items to the current user
user_list_items.put();
示例2: get
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import gql [as 别名]
def get(self):
c_per = memcache.get('current_person')
if not c_per:
c_user = users.get_current_user()
if not c_user:
self.redirect(users.create_login_url(self.request.uri))
return
c_per = Person.gql("WHERE user = :1",c_user).get()
if not c_per:
c_per = Person( user = c_user )
memcache.add('current_person',c_per,PERSON_EXPIRE_TIME)
if not c_per.schedule:
self.response.out.write(template.render('noscheds.html',{}))
else:
self.response.out.write(template.render('home.html',{}))