コード例 #1
0
ファイル: getversions.py プロジェクト: sagarsane/version.is
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()