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


Python Map.get_by_id方法代码示例

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


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

示例1: api_taks

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def api_taks(id=-1):
	if request.method == 'GET':
		map = Map.get_by_id(id)
		if map is None:
			return json_success({})
		else:
			return json_success(map.Get())
	if request.method == 'DELETE':
		map = Map.get_by_id(id)
		if map is None:
			return json_response(code=400, message="Map does not exist")
		map.Delete()
		return json_response(code=200,message="Success")
开发者ID:kylepotts,项目名称:droptak-web,代码行数:15,代码来源:app.py

示例2: favorite_mapsForUser

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def favorite_mapsForUser(userid = -1):
	if userid <= 0:
		return json_response(code=400)
	user = Account.get_by_id(userid)
	if user is None:
		return json_response(code=400)

	if request.method == 'GET': # done
		#	GET: returns json array of information about user's map objects
		return json_success(user.getFavorites())

	mapid = getValue(request, "mapid", "")
	if not mapid:
		return json_response(code=400)
	map = Map.get_by_id(int(mapid))
	if map is None:
		return json_response(code=400)
	if request.method == 'POST':
		if not map.key.integer_id() in user.favoriteMaps:
			user.favoriteMaps.append(map.key.integer_id())
			user.put()
		return json_response(code=200)
	
	if request.method == 'DELETE':
		if map.key.integer_id() in user.favoriteMaps:
			user.favoriteMaps.remove(map.key.integer_id())
			user.put()
		return json_response(code=200)
开发者ID:kylepotts,项目名称:droptak-web,代码行数:30,代码来源:app.py

示例3: newTak

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def newTak():
	name = getValue(request, "name", None)
	uid = getValue(request, "userid", None)
	lat = getValue(request, "lat", None)
	lng = getValue(request, "lng", None)
	if not ( name and lat and lng and uid):
		return json_response(code=400)
	mapid = getValue(request, "mapid", None)
	map = None
	if uid is not None:
		user = Account.get_by_id(int(uid))
		if user is None:
			return json_response(code=400)
	if mapid is not None:
		map = Map.get_by_id(int(mapid))
	if map is None:
		map = Map(creator=user.name,creatorId=int(uid),name='Untitled',adminIds=[int(uid)])
		key = map.put()
		mapid = key.id()
		account = Account.get_by_id(int(uid))
		account.adminMaps.append(int(mapid))
		account.put()
	tak  = Tak(lng=lng,lat=lat, creator=user.name, name=name,mapId=int(mapid),creatorId=int(uid))
	key = tak.put()
	map.takIds.append(key.integer_id())
	map.put();
	return json_success(tak.Get())
开发者ID:kylepotts,项目名称:droptak-web,代码行数:29,代码来源:app.py

示例4: mapData

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def mapData(mapid = -1):
	if mapid <= 0:
		return json_response(code=400)
	map = Map.get_by_id(mapid)
	if map is None:
		return json_response(code=400)

	if request.method == 'GET': # done
		# returns json map info
		return json_success(map.Get())

	if request.method == 'DELETE': #todo
		# DELETE: used to delete a map object and all associated tak objects, parameters: none
		map.Delete()
		return json_response(code=200,message="Success")
		

	if request.method == 'PUT': #todo
		#PUT: 	used to update map in database, parameters: (any map parameter)
		# return json map object
		newName = request.args.get("name","")
		newIsPublic = request.args.get("isPublic","")
		newOwner = request.args.get("owner","")
		map.Put(newName=newName,newIsPublic=newIsPublic,newOwner=newOwner)
		return json_response(code=200,message="Success")
开发者ID:kylepotts,项目名称:droptak-web,代码行数:27,代码来源:app.py

示例5: maps

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def maps():
	userMaps = getMaps(session['userId'])
	listOfMaps = []
	for mapId in userMaps:
		logging.info(mapId)
		aMap = Map.get_by_id(mapId)
		listOfMaps.append(aMap.to_dict())
	return json_success(listOfMaps)
开发者ID:kylepotts,项目名称:droptak-web,代码行数:10,代码来源:app.py

示例6: taks

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def taks(mapId=-1, str=''):
	if mapId == -1:
		return redirect('/app')
	map = Map.get_by_id(mapId)
	if map is None:
		return redirect('/app')
	taks = map.to_dict()['taks']
	return render_template('view_taks.html',taks = taks, mapName=map.name, mapid=map.key.integer_id(), id=int(session['userId']))
开发者ID:kylepotts,项目名称:droptak-web,代码行数:10,代码来源:app.py

示例7: delete_tak

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def delete_tak(mapid=-1, takid=-1):
	if request.method == 'DELETE':
		map = Map.get_by_id(mapid)
                logging.info("DELETE " + str(mapid))
                if map is not None:
                        # remove taks in map
                        tak = Tak.get_by_id(int(takid))
                        logging.info("_DELETE sub-tak" + str(takid))
                        if tak is not None:
                     		   tak.key.delete()
                        return "Success"
                return "Map does not exist"
开发者ID:kylepotts,项目名称:droptak-web,代码行数:14,代码来源:app.py

示例8: create_tak

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def create_tak():
	if request.method == 'POST':
		# login required
		mapId = getValue(request, "mapId", "")
		logging.info("mapId="+mapId)
		map = Map.get_by_id(int(mapId))
		if map is None:
			return jsonify(message="Map does not exist", response=400) 
		logging.info("mapid %s" %mapId)
		name = getValue(request, "title", "")
		lat = getValue(request, "lat", "")
		lng = getValue(request, "lng", "")
		#user = getValue(request, "user", "")
		#change form to not supply user
		user = session['username']
		uid = session['userId']
			
		if not ( user and lat and lng ):
			return jsonify(message="Bad Request", response=400)
			# check if args blank

		logging.info("Add lat %s, lng %s" %(lat, lng) )
		tak  = Tak(lng=lng,lat=lat, creator=user, name=name,mapId=int(mapId),creatorId=int(uid))
		key = tak.put()
		map.takIds.append(int(key.id()))
		map.put();
		return json_success(tak.to_dict())

	if request.method == 'GET': 
		# return list of maps too for selecting
		listOfMaps = []
		mapIds = getMaps(session['userId'])
		for mapid in mapIds:
			ownMap = Map.get_by_id(mapid)
			listOfMaps.append(ownMap)

		return render_template('create_tak.html', uid=session['userId'])
开发者ID:kylepotts,项目名称:droptak-web,代码行数:39,代码来源:app.py

示例9: api_map

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def api_map():
	if request.method == 'POST':
		userName = request.args.get("username","")
		mapName = request.args.get("mapname","")
		userId = request.args.get("userId","")
		userId = str(userId.encode('utf-8').decode('ascii', 'ignore'))
		uid = int(userId)
		ownMap =Map(creator=userName,creatorId=uid,name=mapName)
		key = ownMap.put()
		return json_success({"mapId":key.integer_id()}) 

	if request.method == 'GET':
		id = request.args.get("id","")
		ownMap = Map.get_by_id(int(id))
		return json_success({"creator":ownMap.creator,"name":ownMap.name,"creatorId":ownMap.creatorId,"id":int(id)})
开发者ID:kylepotts,项目名称:droptak-web,代码行数:17,代码来源:app.py

示例10: mapAdmin

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def mapAdmin(mapid=-1,email=""):
	if mapid <= 0:
		return json_response(code=400)
	if email == "":
		return json_response(code=400)

	map = Map.get_by_id(mapid)

	if map is None:
		return json_response(code=400)

	adminAccount = Account.query(Account.email == email).get()

	if adminAccount is None:
		return json_response(code=400)
	userid = adminAccount.key.integer_id()

	if request.method == 'POST':
		if userid not in map.adminIds:
			map.adminIds.append(userid)
			map.put()

		else:
			return json_success(adminAccount.Get())

		if mapid not in adminAccount.adminMaps:
			adminAccount.adminMaps.append(mapid)
			adminAccount.put()
			
		return json_success(adminAccount.Get())

	if request.method == 'DELETE':
		logging.info("delete")
		if userid not in map.adminIds:
			return json_response(code=400)

		if mapid not in adminAccount.adminMaps:
			return json_response(code=400)

		if adminAccount.key.integer_id() == map.creatorId:
			return json_response(code=400)

		map.adminIds.remove(userid)
		adminAccount.adminMaps.remove(mapid)
		map.put()
		adminAccount.put()
		return json_response(code=200)
开发者ID:kylepotts,项目名称:droptak-web,代码行数:49,代码来源:app.py

示例11: copytak

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def copytak(takid = -1):
	if takid <= 0:
		return json_response(code=400)
	tak = Tak.get_by_id(takid)
	if tak is None:
		return json_response(code=400)
	mapid = getValue(request, "mapid", "")
	if mapid == '':
		return json_response(code=400)
	newmap = Map.get_by_id(int(mapid))
	if newmap is None:
		return json_response(code=400)
	newtak  = Tak(lng=tak.lng,lat=tak.lat, creator=tak.creator, name=tak.name,mapId=newmap.key.integer_id(),creatorId=tak.creatorId)
	newtak.metadata = tak.metadata
	key = newtak.put()
	newmap.takIds.append(key.integer_id())
	newmap.put();
	return json_success(newtak.Get())
开发者ID:kylepotts,项目名称:droptak-web,代码行数:20,代码来源:app.py

示例12: admin_add

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def admin_add(mapId,email):
	if request.method == 'POST':
		logging.info("email="+email)
		user = session['username']
		uid = session['userId']
		map = Map.get_by_id(mapId)
		adminAccount = Account.query(Account.email == email).get()
		if adminAccount == None:
			return json_response(message="No Account with that email exists",code=400)

		adminId = adminAccount.key.integer_id()
		if adminId not in map.adminIds:
			map.adminIds.append(adminId)
			map.put()
		if mapId not in adminAccount.adminMaps:
			adminAccount.adminMaps.append(mapId)
			adminAccount.put()

		return '200'
开发者ID:kylepotts,项目名称:droptak-web,代码行数:21,代码来源:app.py

示例13: newMap

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def newMap(userid='', name='', public=''):
	if not (name and public and userid):
		return json_response(code=400);
	user = Account.get_by_id(int(userid))
	if user is None:
		return json_response(code=400);
	if public == 'true':
		public = True
	else: # default false if not set
		public = False
	for mapid in user.adminMaps:
			map = Map.get_by_id(int(mapid))
			if map is not None and map.creatorId == int(userid) and map.name == name:
				return json_response(message="You already have a map of that name", code=400);
	map = Map(creator=user.name,creatorId=int(userid),name=name,adminIds=[int(userid)], public=public)
	key = map.put()
	# add map to user's list of maps
	user.adminMaps.append(key.integer_id())
	user.put()
	#return map json
	return json_success(map.to_dict());
开发者ID:kylepotts,项目名称:droptak-web,代码行数:23,代码来源:app.py

示例14: search

# 需要导入模块: from Map import Map [as 别名]
# 或者: from Map.Map import get_by_id [as 别名]
def search():
	if request.method == 'GET':
		maps = []
		mapIds = []
		queryType=request.args.get("queryType","")
		query = request.args.get("query","")
		uid = session['userId']
		account = Account.get_by_id(uid) 
		logging.info("searching for " + queryType + " " + query)
		mapQuery = Map.query(Map.public == True)
		for map in mapQuery:
			if queryType == 'searchMaps':
				if(query.lower() == map.name.lower()):
					logging.info("match!")
					maps.append(map)
					mapIds.append(map.key.integer_id())
		for mapId in account.adminMaps:
			m = Map.get_by_id(mapId)
			if (query.lower() == m.name.lower()):
				if mapId not in mapIds:
					maps.append(m)
		logging.info(len(maps))
		return render_template('search.html',maps=maps)
开发者ID:kylepotts,项目名称:droptak-web,代码行数:25,代码来源:app.py


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