Just in case anyone runs into the same issue, I'm including my model.init and websetup:
"""=========================__init__.py========================="""
"""The application's model objects"""
from quickwiki.model.meta import Session, Base
def init_model(engine):
"""Call me before using any of the tables or classes in the model"""
Session.configure(bind=engine)
import logging
import re
import sets
from docutils.core import publish_parts
from pylons import url
from quickwiki.lib.helpers import link_to
log = logging.getLogger(__name__)
# disable docutils security hazards:
# http://docutils.sourceforge.net/docs/howto/security.html
SAFE_DOCUTILS = dict(file_insertion_enabled=False, raw_enabled=False)
wikiwords = re.compile(r"\b([A-Z]\w+[A-Z]+\w+)", re.UNICODE)
from sqlalchemy import orm
import sqlalchemy as sa
pages_table = sa.Table('pages', Base.metadata,
sa.Column('title', sa.types.Unicode(40), primary_key=True),
sa.Column('content', sa.types.UnicodeText(), default='')
)
class Page(object):
def __init__(self, title, content=None):
self.title = title
self.content = content
def get_wiki_content(self):
"""Convert reStructuredText content to HTML for display, and
create links for WikiWords
"""
content = publish_parts(self.content, writer_name='html',
settings_overrides=SAFE_DOCUTILS)['html_body']
titles = sets.Set(wikiwords.findall(content))
for title in titles:
title_url = url(controller='pages', action='show', title=title)
content = content.replace(title, link_to(title, title_url))
return content
def __unicode__(self):
return self.title
__str__ = __unicode__
orm.mapper(Page, pages_table)
"""=========================websetup.py========================="""
"""Setup the QuickWiki application"""
import logging
import pylons.test
from quickwiki.config.environment import load_environment
from quickwiki.model.meta import Session, Base
from quickwiki import model
log = logging.getLogger(__name__)
def setup_app(command, conf, vars):
"""Place any commands to setup quickwiki here"""
load_environment(conf.global_conf, conf.local_conf)
# Create the tables if they don't already exist
log.info("Creating tables...")
Base.metadata.create_all(bind=Session.bind)
log.info("Successfully set up.")
log.info("Adding front page data...")
page = model.Page(title=u'FrontPage',
content=u'**Welcome** to the QuickWiki front page!')
Session.add(page)
Session.commit()
log.info("Successfully set up.")