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


Python Place.key方法代码示例

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


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

示例1: save_place

# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import key [as 别名]
	def save_place( self, name, geojson ):
		owner = self.auth.user.auth_id
		place = Place( name=name, owner=owner, geojson=geojson )
		place.put()
		key = str( place.key() )
		self.session['current_place'] = key
		return {
			'key': str( place.key() )
		}
开发者ID:geary,项目名称:claslite,代码行数:11,代码来源:handlers.py

示例2: add_places

# 需要导入模块: from models import Place [as 别名]
# 或者: from models.Place import key [as 别名]
    def add_places(self, user):
    
        # Add 10 Places
        places = [
            'the CN Tower',
            'the Eiffel Tower',
            'Athens Greece',
            'the Great Pyramids',
            'the Great Wall of China',
            'the Louvre',
            'the Palace of Versailles',
            'Sydney Australia',
            'the Grand Canyon',
            'Bora Bora'
        ]
        
        self.response.out.write('<hr/>Adding places to go<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 places:
            place = Place()
            place.title = name
            place.put()
            
            # Add Reference to the Place from User
            user_list_item = UserListItem()
            user_list_item.user = user
            user_list_item.list_item = place
            
            # Update the list of items the user has
            user_list_items.list_items.append(place.key())
            
            # Add the specifics of the user list item linkage
            user_list_item = UserListItem()
            user_list_item.user = user
            user_list_item.list_item = place
            one_year = datetime.timedelta(days=365)
            today = datetime.datetime.today()
            user_list_item.date_due = today + one_year
            user_list_item.put()            

            self.response.out.write('Added %s<br/>' % place)
开发者ID:mpurdon,项目名称:Buckets,代码行数:50,代码来源:reset.py


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