Created
February 2, 2011 23:51
-
-
Save maraca/808761 to your computer and use it in GitHub Desktop.
Shows entries in DataStore for an appengine application. use /populate/ to add 1000 entries. each entry is representend with the timestamp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Copyright 2007 Google Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
from google.appengine.ext import webapp | |
from google.appengine.ext.webapp import util | |
from google.appengine.ext import db | |
import time | |
class User(db.Model): | |
"""Models """ | |
name = db.StringProperty(required=True) | |
class MainHandler(webapp.RequestHandler): | |
def get(self): | |
users = User.all() | |
init_time = time.time() | |
for user in users: | |
self.response.out.write(user.name) | |
self.response.out.write('<br />') | |
end_time = time.time() | |
self.response.out.write('Total time : %f milliseconds ' % | |
(end_time - init_time) ) | |
class PopulateHandler(webapp.RequestHandler): | |
def get(self): | |
for user in range(1000): | |
User(name=str(time.time())).put() | |
def main(): | |
application = webapp.WSGIApplication([ | |
('/', MainHandler), | |
('/populate/', PopulateHandler), | |
], | |
debug=True) | |
util.run_wsgi_app(application) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment