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


Python Location.put方法代码示例

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


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

示例1: add_location

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import put [as 别名]
def add_location(data, location_key=""):
    if location_key:
        location = Location.get_by_id(location_key)
    else:
        location_id = slugify(data["name"])
        temp_location_id = location_id
        while True:
            count = 1
            if Location.get_by_id(temp_location_id):
                temp_location_id = location_id + str(count)
                count += 1
            else:
                location = Location(id=temp_location_id)
                break

    if data["name"]:
        location.name = data["name"]

    if data["needs"]:
        location.needs = data["needs"]

    if data["centers"]:
        location.centers = data["centers"]

    if data["latlong"]:
        location.latlong = data["latlong"]

    if data["featured_photo"]:
        location.featured_photo = data["featured_photo"]

    if data["death_count"]:
        location.death_count = int(data["death_count"])

    if data["death_count_text"]:
        location.death_count_text = data["death_count_text"]

    if data["affected_count"]:
        location.affected_count = int(data["affected_count"])

    if data["affected_count_text"]:
        location.affected_count_text = data["affected_count_text"]

    if data["status_board"]:
        location.status_board = data["status_board"]

    if data["needs"]:
        location.needs = data["needs"]

    if data["status"]:
        location.status = data["status"]

    if data["images"]:
        location.images = data["images"]

    if data["hash_tag"]:
        location.hash_tag = data["hash_tag"]

    location.put()
    return location
开发者ID:rileonard15,项目名称:bangonph,代码行数:61,代码来源:functions.py

示例2: post

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import put [as 别名]
  def post(self, request_id):
    location = self.request.get('location')
    # Get request
    request = ndb.Key(urlsafe=request_id).get()
    location = location.split('^')

    # Check if location has been previously used
    existing_location = Location.query(Location.name == location[0], Location.address == location[1]).get()
    if existing_location is None:
      # Add new location
      categories = location[3].split(',')
      coordinates = location[4].split(' ')
      new_location = Location()
      new_location.name = location[0]
      new_location.address = location[1]
      new_location.image_url = location[2]
      for c in categories:
        new_location.categories.append(c)
      new_location.longitude = float(coordinates[0])
      new_location.latitude = float(coordinates[1])
      new_location.put()
      
    else:
      new_location = existing_location

    if request != None:
      # Check if already appended
      add = True
      if len(request.bidders) > 0:
        for bid in request.bidders:
          bid = bid.get()
          if bid.name == self.user_model.username:
            print "Already bid"
            add = False
      if add is True:
          print "Haven't bid"
          bidder = Bidder()
          bidder.sender = self.user_model.key
          bidder.location = new_location.key
          bidder.name = self.user_model.username
          bidder.bid_time = datetime.datetime.now() - datetime.timedelta(hours=8)
          bidder.price = request.price
          bidder.put()
          request.bidders.append(bidder.key)
          request.status = "pending"
          request.put()
    else:
      print "Already connected"

    self.redirect('/feed')
开发者ID:Qiwis,项目名称:foodie,代码行数:52,代码来源:foodie_requests.py

示例3: list_location

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import put [as 别名]
def list_location():
    l = Location()
    l.lat = 1.0
    l.lng = 1.0
    l.put()

    vals = ''
    q = Location.query()

    n = q.count()

    for e in q:
        vals += str(e) + '<br><br>'
        # e.key.delete()

    return '<h3>%d</h3><br>%s' % (n, vals)
开发者ID:AndersonQ,项目名称:appengine-python-demo,代码行数:18,代码来源:api_app.py

示例4: add_location

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import put [as 别名]
def add_location(request, loc_type, map_source ="google-maps", visibility = "private"):
    location = Location(owner = users.get_current_user(), 
                            map_source =map_source, loc_type = loc_type)
    location.visibility = visibility
    
    if loc_type == "extent":
        location.name = request.get('loc-name')
        location.latitude = float(request.get('latitude'))
        location.longitude =float(request.get('longitude'))
        location.zoom = int(request.get('zoom'))
    elif loc_type == "point":
        location.name = request.get('point-name')
        location.latitude = float(request.get('latitude-point'))
        location.longitude =float(request.get('longitude-point'))
        location.zoom = int(request.get('zoom-point'))
    tkn = location.buildToken()
    location.token = tkn
        
    location.put()
    return location.toJSON()
开发者ID:luiscberrocal,项目名称:pygooglemaps,代码行数:22,代码来源:googlemaps.py

示例5: post

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import put [as 别名]
 def post(self):
     logging.error(dir(self.auth))
     if not self.auth.user:
         return Response('Error: authenticate first')
     place_key_name = self.request.form.get('place_key_name')
     l = Location.all().filter('osm =', place_key_name).fetch(1)
     if not l:
         l = Location(osm=place_key_name)
         l.put()
     else:
         l = l[0]
     c = Checkin(user=self.auth.user, location=l)
     osmpoi = OSMPOI.get_by_key_name(place_key_name)
     place_name = osmpoi.name
     if place_name:
         c.place_name = place_name
     else:
         c.place_key_name = osmpoi.key().name()
     c.user_name = self.auth.user.username
     c.put()
     return Response('Success %s, %s' % (self.auth.user, place_key_name))
开发者ID:dudarev,项目名称:ololog,代码行数:23,代码来源:handlers.py

示例6: post

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import put [as 别名]
  def post(self):

    location = Location()

    logging.info(self.request.get('data'))

    data = simplejson.loads(self.request.get('data'))

    logging.info(data)

    if users.get_current_user():
      location.author = users.get_current_user()
      location.title = data['title']
      location.address = data['address']
      location.city =  data['city']
      location.state =  data['region']
      location.location= data['lat'] + "," + data['lng']
      #location.location = "14.584892,121.05747"
      location.put()

      self.response.out.write('OK')
开发者ID:jasontorres,项目名称:carparkfinder,代码行数:23,代码来源:main.py

示例7: get

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import put [as 别名]
    def get(self):
        location_key = ndb.Key('Location', 'HomeBase')
        exit_key = ndb.Key('Exit', 'HomeBase')


        # LOCATION_MAP = [ home_base, kitchen]
        command = self.request.get("command")

        exit = Exit(name="exit", description="exit desc", command="go exit")
        exit_key= exit.put()
        home_base = Location(name="asd", description="DESC", exits=exit_key)
        exit = exit_key.get()
        home_key = home_base.put()
        exit.target_loc = home_key
        exit_key = exit.put()


        user = users.get_current_user() #is this supposed to be None?

        if user is None:
            self.response.write('Please log in to continue...')
            self.response.headers['Content-Type'] = 'text/plain'
            return

        self.response.write('>> ' + command + "<br>")

        if None not in USERS:
            #set up initial user
            USERS[None] = home_base
            current_location = home_base
        else:
            current_location = USERS[None]

        self.request.current_location = current_location
        user = users.get_current_user()
        if command == "look":
            self.look()
        exit = current_location.exits.get()
        if command == exit.command:
            self.response.write("Changing location")
            USERS[None] = exit.target_loc.get()
            self.request.current_location = exit.target_loc.get()
            self.look()

        self.response.headers['Content-Type'] = 'text/plain'
开发者ID:tankorsmash,项目名称:tenderfootproapp,代码行数:47,代码来源:main.py

示例8: from_utc

# 需要导入模块: from models import Location [as 别名]
# 或者: from models.Location import put [as 别名]
print 'ADMINS:'
for a in Admin.all():
    print a.display, a.name, a.passhash, a.created

import json

def from_utc(utcTime,fmt="%Y-%m-%dT%H:%M:%S"):
    """
    Convert UTC time string to time.struct_time
    """
    # change datetime.datetime to time, return time.struct_time type
    return datetime.datetime.strptime(utcTime, fmt)

for loc in json.load(open(sys.argv[1])):
    l = Location( building = string.capitalize(loc['building']),
                  floor = loc['floor'],
                  room = loc['room'])
    l.put()
    print (l)

for comf in json.load(open(sys.argv[2])):
    c = Comfort(loc_building = string.capitalize(comf['loc_building']),
                loc_floor = comf['loc_floor'],
                loc_room = comf['loc_room'],
                level = comf['level'],
                timestamp = from_utc(comf['timestamp']))
    c.put()
    print (c)


开发者ID:BucknellLaunch,项目名称:thermal-sensing,代码行数:30,代码来源:restore.py


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