app/soc/models/seed_db.py
changeset 1902 be3dbaa17114
parent 1901 5a98e8a8efb5
child 1903 9d95d3e20773
equal deleted inserted replaced
1901:5a98e8a8efb5 1902:be3dbaa17114
   359   memcache.flush_all()
   359   memcache.flush_all()
   360 
   360 
   361   return http.HttpResponse('Done')
   361   return http.HttpResponse('Done')
   362 
   362 
   363 
   363 
       
   364 def seed_user(request, i):
       
   365   """Returns the properties for a new user entity.
       
   366   """
       
   367 
       
   368   properties = {
       
   369       'key_name': 'user_%(num)d' % i,
       
   370       'link_id': 'user_%(num)d' % i,
       
   371       'account': users.User(email='user_%(num)d@example.com' % i),
       
   372       'name': 'User %(num)d' % i,
       
   373       }
       
   374 
       
   375   return properties
       
   376 
       
   377 
   364 def seed_many(request, *args, **kwargs):
   378 def seed_many(request, *args, **kwargs):
   365   """Seeds many instances of the specified type.
   379   """Seeds many instances of the specified type.
   366   """
   380   """
   367 
   381 
   368   get_args = request.GET
   382   get_args = request.GET
   369 
   383 
   370   if not dicts.containsAll(get_args, ['goal', 'start', 'end', 'seed_type']):
   384   if not dicts.containsAll(get_args, ['goal', 'start', 'end', 'seed_type']):
   371     return http.HttpResponse('Missing get args.')
   385     return http.HttpResponse('Missing get args.')
   372 
   386 
   373   seed_types = {
   387   seed_types = {
       
   388     'user': (seed_user, User),
   374     }
   389     }
   375 
   390 
   376   goal = int(get_args['goal'])
   391   goal = int(get_args['goal'])
   377   start = int(get_args['start'])
   392   start = int(get_args['start'])
   378   end = int(get_args['end'])
   393   end = int(get_args['end'])