本文整理汇总了Python中model.Point.put方法的典型用法代码示例。如果您正苦于以下问题:Python Point.put方法的具体用法?Python Point.put怎么用?Python Point.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.Point
的用法示例。
在下文中一共展示了Point.put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model import Point [as 别名]
# 或者: from model.Point import put [as 别名]
def post(self):
point = Point()
point.title = self.request.get('title')
if self.request.get('path'):
point.path = True
else:
point.path = False
point.content = cgi.escape(self.request.get('content')).replace('\r\n','<br>').replace('\n','<br>');
point.lat = float(self.request.get('lat'))
point.lng = float(self.request.get('lng'))
dt = self.request.get('visit')
if dt:
point.date = datetime.datetime.strptime(dt,"%Y-%m-%d")
else:
point.date = datetime.datetime.now()
point.dateStr = point.date.strftime('%b %d, %Y')
if self.request.get('image'):
point.img = db.Blob(images.resize(self.request.get('image'),500,500))
point.put()
self.redirect('/admin')
示例2: post
# 需要导入模块: from model import Point [as 别名]
# 或者: from model.Point import put [as 别名]
def post(self):
user = users.get_current_user()
if user == None:
self.response.out.write()
else:
lat = float(self.request.get("lat"))
lon = float(self.request.get("lon"))
hash = geohash.encode(lat, lon)
point = Point()
point.geohash = hash
point.owner = users.get_current_user()
point.put()
template_values = {"method": "post"}
self.response.headers["Content-Type"] = "application/json"
self.response.out.write('{result:"OK", geohash:"' + hash + '"}')
示例3: post
# 需要导入模块: from model import Point [as 别名]
# 或者: from model.Point import put [as 别名]
def post(self):
a, d = self.request.get('author'), self.request.get('description') # error: missing either key
try:
schedString = self.request.get('schedulestring') # error: missing parameter
jsonSched = simplejson.loads(schedString) # error: bad json
s = Schedule(auth = a, desc = d)
s.put() # error: some puts succeed while others fail
for pt in jsonSched["points"]: # error: not an object, or no "points" key
p = Point(sched = s, location = map(int, pt), phase = ['R', 'R']) # error: setting all phases to RR
p.put() # error: some puts succeed while others fail
# schedule should be post-ed as json string
# so parse the string into Schedule's and Point's, then save it
# (check out previous versions of scheduler.py for examples of saving)
self.response.out.write(simplejson.dumps({'success': 'Schedule was successfully saved!'})) # maybe add the schedule's id?
except Exception, e:
self.response.out.write(simplejson.dumps({'error': e.message}))