On Sat, 17 Dec 2005 12:24:00 +0800, "limodou" <[EMAIL PROTECTED]> said: > I'm reading the doc about one to many, and I saw that in the document is: > > User.mapper = mapper(Mapper, users, properties = dict( > relation(Address.mapper, lazy=True, private=True) > )) > > I didn't know Mapper is from where and it seems dict lacks the key. > May be it should be: > > User.mapper = mapper(User, users, properties = dict( > addresses = relation(Address.mapper, lazy=True, private=True) > )) >
Which doc are you referring to? It appears to be fixed in the online version (unless you're looking at something else). > And I also cann't distinguish the differences between OneToMany and > OneToOne, in the mapping code. Can someone show me the differences > between them in code? There's no difference between them in the mapping code (assuming you mean setting up the relations in the mapper). The actual type of relation is determined by the way the underlying tables are specified. This is a core tenet in SQLAlchemy as Mike said in an email a while back on m:n - "I have not gone down the road of making functions like "manytoone", "onetomany", "foreignkey", "manytomany", etc. When you make method names like that, you are defining your relationships multiple times; once when you set up all your Table objects, and then again when you set up your mappers. I like that the Table structures, in most cases, define what relations actually occur. Explicit method naming to define the specific type of relationship is more appropriate for SQLObject since the table metadata, relationships, and object-property mapping is set up all monolithically within a single class definition, and it needs those different method names to tell it what the table relationships are. SQLAlchemy knows how to look at your tables and decide what the relationship naturally is. Occasionally you might want to specify "uselist=False" to force a one-to-one, and for a very small percentage of objects you might want to use the primaryjoin/secondaryjoin options for total customization." Robert ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Sqlalchemy-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

