Dear list...

I'm on a documentation frenzy now in my current Pylons project. And I'm 
using Sphinx for that purpose. All my controllers and helper functions are 
documented automatically. Great. Unfortunately Sphinx fails to create 
module documentation for my models. I'm staying close to the "Using 
SQLAlchemy with Pylons" [0] way as documented on the Pylons wiki. This is 
the output on my console:

=================================
$> make html
mkdir -p _build/html _build/doctrees
sphinx-build -b html -d _build/doctrees   . _build/html
Sphinx v0.4.2, building html
trying to load pickled env... not found
building [html]: targets for 4 source files that are out of date
updating environment: 4 added, 0 changed, 0 removed
reading... antrag-allgemein antrag-erstellen api Exception occurred:
  File "/var/lib/python-support/python2.5/sqlalchemy/schema.py", line 101, 
in __call__
    "columns on an existing Table object." % key)
InvalidRequestError: Table 'applications' is already defined for this 
MetaData instance.  Specify 'useexisting=True' to redefine options and 
columns on an existing Table object.
The full traceback has been saved in /tmp/sphinx-err-lBwkYm.log, if you 
want to report the issue to the author.
Please also report this if it was a user error, so that a better error 
message can be provided next time.
Send reports to [EMAIL PROTECTED] Thanks!
make: *** [html] Error 1
=================================

I have a table "applications" here - but it's only defined once. My 
model/__init__.py looks roughly like (less interesting parts removed):

=================================
# -*- coding: utf-8 -*-

import sqlalchemy as sql
import sqlalchemy.orm as orm
from myapp.model import meta

def init_model(engine):
    sm = orm.sessionmaker(autoflush=True, transactional=True, bind=engine)
    meta.engine = engine
    meta.Session = orm.scoped_session(sm)

applications_table = sql.Table(
    'applications', meta.metadata,
    sql.Column('id', sql.Integer, primary_key=True),
    sql.Column('applicant', sql.Unicode(8), nullable=False),
    sql.Column('created_date', sql.DateTime(), default=sql.func.now()),
    sql.Column('valid_until', sql.DateTime()),
    sql.Column('description', sql.Unicode(100)),
    sql.Column('reason', sql.Unicode(4000)),
    sql.Column('status', sql.Integer, nullable=False),
)

class Application(object): pass

orm.mapper(Application, applications_table)
=================================

Does anyone have an idea what's going wrong? And whether it needs to fixed 
in Sphinx, SQLAlchemy (I'm on 0.4.6) or my code? Mike Orr assumed that it 
could be that Sphinx loads the module twice to tear out docstrings.

Cheers
 Christoph

[0] 
http://wiki.pylonshq.com/display/pylonsdocs/Using+SQLAlchemy+with+Pylons

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to