Skip to content

Instantly share code, notes, and snippets.

@andialbrecht
Created May 24, 2013 12:39
Show Gist options
  • Save andialbrecht/5643225 to your computer and use it in GitHub Desktop.
Save andialbrecht/5643225 to your computer and use it in GitHub Desktop.
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: demo.application
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