def main(): # Check if defaults have been installed installed_defaults = memcache.get("installed_defaults") if installed_defaults is None: installed_defaults = Setting.all().filter('name = ', 'installed_defaults').get() if installed_defaults is None: logging.info("Installing default statuses") Status.install_defaults() if not memcache.add("installed_defaults", True): logging.error("Memcache set failed.") application = webapp.WSGIApplication(ROUTES, debug=config.DEBUG) wsgiref.handlers.CGIHandler().run(application)
def post(self): Status.install_defaults() self.redirect("/admin")
# all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. from google.appengine.ext import db from models import Status, Service, Event from datetime import datetime, timedelta, date # Create the default statuses Status.install_defaults() # Create Services service = { "name": "Service Foo", "slug": "service-foo", "description": "Scalable and reliable foo service across the globe", } services = [] for i in "ABCDEFGHIJ": foo = Service(name=service["name"] + i, slug=service["slug"] + i, description=service["description"]) foo.put() services.append(foo)