On Aug 27, 2008, at 2:57 AM, Christoph Haas wrote:

> 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.


my initial impression is that Sphinx is loading modules artificially  
(and executing them) despite their already being present in  
sys.modules.    The error indicates that the same MetaData instance is  
being used to create "applications_table" twice.    Definitely ask the  
Sphinx folks about this one.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to