old_contents: # This file is part of Moksha.
  # Copyright (C) 2008-2010  Red Hat, Inc.
  # 
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Affero General Public License as
  # published by the Free Software Foundation, either version 3 of the
  # License, or (at your option) any later version.
  # 
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU Affero General Public License for more details.
  # 
  # You should have received a copy of the GNU Affero General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
  """Setup the moksha application"""
  import logging
  import transaction
  
  from tg import config
  from paste.deploy import appconfig
  
  from moksha.config.environment import load_environment
  
  log = logging.getLogger(__name__)
  
  def setup_config(command, filename, section, vars):
      """Place any commands to setup moksha here"""
      conf = appconfig('config:' + filename)
      load_environment(conf.global_conf, conf.local_conf)
      # Load the models
      from moksha import model
      print "Creating tables"
      model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine)
  
      u = model.User()
      u.user_name = u'manager'
      u.display_name = u'Example manager'
      u.email_address = u'manager@somedomain.com'
      u.password = u'managepass'
  
      model.DBSession.add(u)
  
      g = model.Group()
      g.group_name = u'managers'
      g.display_name = u'Managers Group'
  
      g.users.append(u)
  
      model.DBSession.add(g)
  
      p = model.Permission()
      p.permission_name = u'manage'
      p.description = u'This permission give an administrative right to the bearer'
      p.groups.append(g)
  
      model.DBSession.add(p)
  
      u1 = model.User()
      u1.user_name = u'editor'
      u1.display_name = u'Example editor'
      u1.email_address = u'editor@somedomain.com'
      u1.password = u'editpass'
  
      model.DBSession.add(u1)
      model.DBSession.flush()
  
      transaction.commit()
      print "Successfully setup"
  
new_contents: # This file is part of Moksha.
  # Copyright (C) 2008-2010  Red Hat, Inc.
  # 
  # This program is free software: you can redistribute it and/or modify
  # it under the terms of the GNU Affero General Public License as
  # published by the Free Software Foundation, either version 3 of the
  # License, or (at your option) any later version.
  # 
  # This program is distributed in the hope that it will be useful,
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  # GNU Affero General Public License for more details.
  # 
  # You should have received a copy of the GNU Affero General Public License
  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
  """Setup the moksha application"""
  import logging
  import transaction
  
  from tg import config
  from paste.deploy import appconfig
  
  from moksha.config.environment import load_environment
  
  log = logging.getLogger(__name__)
  
  def setup_config(command, filename, section, vars):
      """Place any commands to setup moksha here"""
      conf = appconfig('config:' + filename)
      load_environment(conf.global_conf, conf.local_conf)
      # Load the models
      from moksha import model
      print "Creating tables"
      model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine)
  
      u = model.User()
      u.user_name = u'manager'
      u.display_name = u'Example manager'
      u.email_address = u'manager@somedomain.com'
      u.password = u'managepass'
  
      model.DBSession.add(u)
  
      g = model.Group()
      g.group_name = u'managers'
      g.display_name = u'Managers Group'
  
      g.users.append(u)
  
      model.DBSession.add(g)
  
      p = model.Permission()
      p.permission_name = u'manage'
      p.description = u'This permission give an administrative right to the bearer'
      p.groups.append(g)
  
      model.DBSession.add(p)
  
      u1 = model.User()
      u1.user_name = u'editor'
      u1.display_name = u'Example editor'
      u1.email_address = u'editor@somedomain.com'
      u1.password = u'editpass'
  
      model.DBSession.add(u1)
      model.DBSession.flush()
  
      # Create some knowledge
      #from moksha.apps.knowledge.model import Entity
      #snake = Entity(u'Python')
      #snake[u'type'] = 'snake'
      #model.DBSession.add(snake)
  
      transaction.commit()
      print "Successfully setup"
  
subject: Disable our fact/entity creation in the websetup, for now