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


Python Person.gql方法代码示例

本文整理汇总了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();
开发者ID:mpurdon,项目名称:Buckets,代码行数:60,代码来源:reset.py

示例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',{}))
开发者ID:raffaine,项目名称:Gotta-Project,代码行数:21,代码来源:main.py


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