moviedemo / moviedemo / websetup / bootstrap.py

# -*- coding: utf-8 -*-
"""Setup the tgtest application"""
from datetime import datetime
import logging
from tg import config
from moviedemo import model
import transaction
from bootalchemy.loader import YamlLoader

def bootstrap(command, conf, vars):
    """Place any commands to setup tgtest here"""

    # <websetup.bootstrap.before.auth
    from sqlalchemy.exc import IntegrityError
    try:
        from moviedemo import model
        print "Adding Bootstrap Data..."
        
        data = """
- Group:
    - {'&managers': {group_name:  managers, display_name:  Managers Group, description:  This permission give an administrative right to the bearer}}
  User:
    - {'&manager': {user_name:  manager, display_name:  Example manager, email_address:  manager@somedomain.com, password: managepass, groups: ['*managers']}}
    - {'&editor':  {user_name:  editor, display_name:  Example editor, email_address:  editor@somedomain.com, password: editorpass}}
  flush:
- Genre:
    - {'&action': {name: action, description: 'car chases, sex and violence'}}
    - {'&animation': {name: animation, description: cartoons and computer rendered flicks}}
    - {'&comedy': {name: comedy, description: funny stuff}}
    - {'&documentary': {name: documentary, description: purely information}}
    - {'&drama': {name: drama, description: makes your girlfriend cry}}
    - {'&sci_fi': {name: sci-fi, description: 'read: furturism'}}
  Director:     
    - {'&robert': {name: Robert Zemeckis}}
    - {'&david' : {name: David Fincher}}
    - {'&andy'  : {name: Andy Wachowski}}
    - {'&larry' : {name: Larry Wachowski}}
    - {'&joel'  : {name: Joel Coen}}
  Movie:
    - description: In 1985, Doc Brown invents time travel; in 1955, Marty McFly accidentally prevents his parents from meeting, putting his own existence at stake
      title: Back to the Future
      release_date:  1985-4-3
      genre: "*sci_fi"
      directors: ["*robert"]
    - description: An office employee and a soap salesman build a global organization to help vent male aggression.
      title: Fight Club
      release_date:  1999-10-14
      genre: "*action"
      directors: ["*david"]
    - description: A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against the controllers of it.
      title: The Matrix
      release_date:  1999-3-31
      genre: "*sci_fi"
      directors: ["*larry", "*andy"]
    - description: '"Dude" Lebowski, mistaken for a millionaire Lebowski, seeks restitution for his ruined rug and enlists his bowling buddies to help get it.'
      title: The Big Lebowski
      release_date:  1998-3-6
      genre: "*comedy"
      directors: ["*joel"]
  flush:
"""
        loader = YamlLoader(model)
        loader.loads(model.DBSession, data)
        transaction.commit()
    except IntegrityError:
        print 'Warning, there was a problem adding your auth data, it may have already been added:'
        import traceback
        print traceback.format_exc()
        transaction.abort()
        print 'Continuing with bootstrapping...'
        

    # <websetup.bootstrap.after.auth>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.