On Sep 11, 2008, at 15:40 , Georg Brandl wrote:
>
> [EMAIL PROTECTED] schrieb:
>> Note the trailing dot in the second occurrence of the import.
>> Immediately after than second import SQLAlchemy throws
>> "ArgumentError:
>> Table 'sometable' is already defined for this MetaData instance."
>
> That's not good and smells like a bug in autodoc. What version of
> Sphinx
> are you using? Can you show me the snippet of reST that contains the
> autodoc directives in question?
This is with Sphinx 0.4.2, tho it also happened with trunk at the end
of last week.
This reST will do it:
:mod:`myapp.model` Module
=================================
.. automodule:: myapp.model
Module Contents
---------------
.. autofunction:: init_model
.. autoclass:: User
One sample myapp/model/__init__.py to go with that would be:
import sqlalchemy as sa
from sqlalchemy import 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)
user_table = sa.Table("users", meta.metadata,
sa.Column("username", sa.types.String(32),
primary_key=True),
sa.Column("password", sa.types.String(32),
nullable=False)
)
class User(object):
"""
User object.
"""
def __init__(self, user, password):
self.id = None
self.username = unicode(user)
self.password = unicode(password)
def __repr__(self):
myclass = self.__class__.__name__
return "%s(%r, %r)" % (myclass, self.username, self.password)
orm.mapper(User, user_table)
And finally myapp/model/meta.py:
from sqlalchemy import MetaData
__all__ = ['Session', 'metadata']
engine = None
Session = None
metadata = MetaData()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sphinx-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sphinx-dev?hl=en
-~----------~----~----~----~------~----~------~--~---