On 12 déc, 00:03, Mike Orr <[email protected]> wrote: > On Sat, Dec 11, 2010 at 6:16 AM, Yohann REBATTU > > <[email protected]> wrote: > > Hello, i'm trying to use the declarative way (recomanded for > > sqlalchemy 0.5+) to set up a pylons model, and i'm stuck with a pretty > > simple many to many relationship. > > > The pylons doc > > (http://www.sqlalchemy.org/docs/orm/tutorial.html#creating-table-class... > > ) doesn't describe this kind of relation, but redirect on sqlAlchemy > > doc : > > (http://www.sqlalchemy.org/docs/orm/tutorial.html#building-a-many-to-m... > > ) > > > this exemple works well in python console, but as i tryed it inside my > > pylons model (http://pastebin.com/gtL4Lec9) > > sqlachemy complain about the group table doesn't exists (maybe > > because, as seen in the doc, the Group object is placed after the > > user_group_table declaration). > > Is it possible you put the declarative and non-declarative tables in > different metadatas? Then creating the tables for one metadata > wouldn't create them for the other. Although I'd expect an error when > the mapper is defined because it can't build the relation. > > -- > Mike Orr <[email protected]>
Thank you, for helping me out ;-) johnathan: i've put all my files in one, but it doesn't change the error cd34: i thought the backref to a many to many relation was the name of a list, ie, backref groups is a list of Group objects, anyway it doesn't change the error to use group instead of groups. Mike, i think you pointed me one the right cause of the error, i double checked my model/meta.py file and it maybe a problem from there: from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import scoped_session, sessionmaker from sqlalchemy import MetaData __all__ = ['Base', 'Session'] # SQLAlchemy session manager. Updated by model.init_model() Session = scoped_session(sessionmaker()) # The declarative Base Base = declarative_base() metadata = MetaData() so i'm really not sure, metadata and Base share the same sqlalchemy session (i hope this last sentence is not that wrong, i'm not familiar yet with all pylons terms) -- You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en.
