Created
May 24, 2013 12:39
-
-
Save andialbrecht/5643225 to your computer and use it in GitHub Desktop.
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
application: your-app-id | |
version: 1 | |
runtime: python27 | |
api_version: 1 | |
threadsafe: true | |
handlers: | |
- url: /.* | |
script: demo.application |
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
import webapp2 | |
import time | |
from google.appengine.ext import db | |
class MyData(db.Model): | |
val = db.IntegerProperty() | |
modified = db.DateTimeProperty(auto_now=True) | |
class MainPage(webapp2.RequestHandler): | |
def get(self): | |
self.response.headers['Content-Type'] = 'text/plain' | |
obj = MyData() | |
obj.val = 1 | |
key = obj.put() | |
self.response.write('modified 1: %s\n' % obj.modified) | |
# time.sleep(1) | |
obj = db.get(key) | |
obj.__class__.modified.auto_now = False | |
self.response.write('value is %s\n' % obj.val) | |
obj.val = 2 | |
obj.put() | |
self.response.write('modified 2: %s\n' % obj.modified) | |
obj.__class__.modified.auto_now = True | |
application = webapp2.WSGIApplication([ | |
('/', MainPage), | |
], debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment