# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### # ScribeEngine - Open Source Blog Software # # --------------------------------------------------------------------------- # # Copyright (c) 2010 Raoul Snyman # # --------------------------------------------------------------------------- # # This program is free software; you can redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the Free # # Software Foundation; version 2 of the License. # # # # 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 General Public License for # # more details. # # # # You should have received a copy of the GNU General Public License along # # with this program; if not, write to the Free Software Foundation, Inc., 59 # # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### """ Setup the ScribeEngine application """ import logging from datetime import datetime from scribeengine.config.environment import load_environment log = logging.getLogger(__name__) def setup_app(command, conf, vars): """Place any commands to setup scribeengine here""" load_environment(conf.global_conf, conf.local_conf) import hashlib import hmac from scribeengine.model.meta import metadata, Session, engine from scribeengine.model import Category, Permission, Post, Variable, \ User, Role # Create the tables if they don't already exist metadata.create_all(bind=engine, checkfirst=True) blog_title = Variable(key=u'blog title', value=u'ScribeEngine') blog_slogan = Variable(key=u'blog slogan', value=u'open source blog software') pylons_cat = Category(name=u'Pylons', url=u'pylons') database_cat = Category(name=u'Database', url=u'database') perm_addposts = Permission(name=u'Add Posts') perm_editmyposts = Permission(name=u'Edit My Posts') perm_delmyposts = Permission(name=u'Delete My Posts') role_admin = Role(name=u'Administrator') role_admin.permissions.extend([perm_addposts, perm_editmyposts, perm_delmyposts]) password = unicode(hmac.new(conf[u'security.salt'], u'omigosh', hashlib.sha256).hexdigest(), u'utf-8') user = User(email=u'raoul.snyman@saturnlaboratories.co.za', password=password, nick=u'raoul') user.roles.append(role_admin) Session.add_all([blog_title, blog_slogan, user]) Session.commit()