i have added metadata.bind = engine to my __init__.py and that don't
change anything.

here is my model (jeux.py) and my __init__.py

### jeux.py
from sqlalchemy import *
from sqlalchemy.orm import mapper, relation
from mortsvivants.model import metadata

jeux_table = Table("jeux", metadata,
    Column("id", Integer, primary_key=True),
    Column("nom", String(255), nullable=False),
    )


class Jeux(object):
    def __init__(self, **kw):
        """automatically mapping attributes"""
        for key, value in kw.iteritems():
            setattr(self, key, value)

mapper(Jeux, jeux_table)

---------------------------------------------------------------------------------------------

### __init__.py

from zope.sqlalchemy import ZopeTransactionExtension
from sqlalchemy.orm import scoped_session, sessionmaker
#from sqlalchemy import MetaData
from sqlalchemy.ext.declarative import declarative_base


maker = sessionmaker(autoflush=True, autocommit=False,
                     extension=ZopeTransactionExtension())

DBSession = scoped_session(maker)
DeclarativeBase = declarative_base()

metadata = DeclarativeBase.metadata


def init_model(engine):
    """Call me before using any of the tables or classes in the
model."""

    DBSession.configure(bind=engine)
    metadata.bind = engine

# Import your model modules here.
from identity import User, Group, Permission
from jeux import Jeux, jeux_table

Can anyone tell me if there is an error in this code ?

thanks.
Thomas.

On 25 sep, 11:35, Antti Niinikoski <[EMAIL PROTECTED]> wrote:
> Just do the following in your __init__.py if you are using DBSprockets
> (initially Albertos code):
>
> def init_model(engine):
>     DBSession.configure(bind=engine) # not really needed if engine is
> bound to metadata but anyway...
>     metadata.bind = engine # <-- add this if using dbsprockets
>
> For more informartion 
> seehttp://groups.google.com/group/dbsprockets/browse_thread/thread/ed794...
>
> Antti
>
> On 24 syys, 22:50, balisong <[EMAIL PROTECTED]> wrote:
>
> > I have the same problem and i don't know how to manually bind the
> > metadata in __init__.py
> > can you explain me how to do this please ?
>
> > On 10 sep, 17:10, "Mark Ramm" <[EMAIL PROTECTED]> wrote:
>
> > > Yea, it seems that issue is the metadata not being bound at the point
> > > where make_form tries to introspect the model.
>
> > > You may need to "manually" bind the metadata in __init__.py in your
> > > model, as is done in a freshly quickstarted project.
>
> > > On Wed, Sep 10, 2008 at 9:44 AM, Antti Niinikoski
>
> > > <[EMAIL PROTECTED]> wrote:
>
> > > > Hello list
>
> > > > I have a problem with thepasterCRUDtool in TG2. I always get the
> > > > following error message:
>
> > > > "Exception: arg1(model) has not been mapped to an sql table
> > > > appropriately"
>
> > > > The exception comes from the make_form method in the form-controller.
> > > > The whole traceback can be found in paste (http://paste.turbogears.org/
> > > > paste/6318).
>
> > > > I have done "pastersetup-app".  And the model works fine without
> > > >CRUD. In my project I use the identity and it uses
> > > > DeclarativeBase.metadata. Could the metadata be the problem?
>
> > > > Does anyone know what I am doing wrong?
>
> > > > TheCRUDtool and TG2 seems very intresting. Thanks!
>
> > > > Regards,
>
> > > > Antti
>
> > > --
> > > Mark Ramm-Christensen
> > > email: mark at compoundthinking dot com
> > > blog:www.compoundthinking.com/blog
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to