Пример #1
0
 def get(self):
   dir = "model/data"
   with open('%s/PetType.csv'%(dir)) as csvfile:
       data = csv.reader(csvfile)
       for row in data:
           PetType.get_or_insert(
             row[0],
             name=row[0],
             name_ja=row[1],
             behavior=row[2].split("|")
           )
   
   with open('%s/PetCategory.csv'%(dir)) as csvfile:
       data = csv.reader(csvfile)
       for row in data:
           PetCategory.get_or_insert(
             row[1],
             name=row[1],
             pet_type=ndb.Key(PetType, row[0]),
             name_ja=row[2]
           )
   
   with open('%s/BreedDog.csv'%(dir)) as csvfile:
       data = csv.reader(csvfile)
       for row in data:
           Breed.get_or_insert(
             row[1],
             pet_type=ndb.Key(PetType, row[0]),
             name=row[1],
             name_ja=row[2]
           )
   with open('%s/BreedCat.csv'%(dir)) as csvfile:
       data = csv.reader(csvfile)
       for row in data:
           Breed.get_or_insert(
             row[1],
             pet_type=ndb.Key(PetType, row[0]),
             name=row[1],
             name_ja=row[2]
           )
Пример #2
0
 def get(self):
   data = {}
   data["pet_types"] = PetType.get()
   data["pet_categories"] = PetCategory.get()
   
   self.SendJson(data)