def projectGet(p, d, filename, refresh): # Refresh meta data about the project if needed if refresh: data = { 'prettyname': d['name'], 'website': d['website'], 'handler': d['handler']['type'] } data = json.dumps(data, separators=(',', ':')) pm = Project.gql('WHERE project = :1', p).get() if pm: pm.data = data else: pm = Project(project=p, data=data) pm.put() # Get version info with specified handler handler = d['handler']['type'] handlerargs = d['handler'] h = testHandler(handler) if h[0]: version = h[1](p, handlerargs) logging.info('current version: ' + version) # Cache version for an hour memcache.set('version:' + p, version, 3600) else: logging.error('invalid Handler!')
def refreshProjectCache(name, sha): # Delete old Project models for the project if they exists for p in Project.gql("WHERE project = :1", name): p.delete() # Delete old ShaCache models for the project if they exists for s in ShaCache.gql("WHERE project = :1", name): s.delete() # Fetch new data, loads and dumps json to remove newlines from the input. (multiline not ok in datastore) data = json.dumps(json.loads(urlfetch.fetch(rawPath(name)).content), separators=(',', ':')) # Put new project data into a Project Model p = Project(project=name, data=data) p.put() # Put new sha hash into a ShaCache Model s = ShaCache(project=name, sha=sha) s.put()