when you say this:

class AlbumComment(object):pass
mapper(AlbumComment, AlbumCommentTable)

#relationship between Albums and Comments
albumCommentMapper = mapper(AlbumComment, AlbumCommentTable, properties
= {'comments':relation(Comment, secondary=AlbumCommentTable,
lazy=False)})

youre making two separate mappers for the AlbumComment class.  you only
want one.  (thats why the error message says, "AlbumComment already has
a primary mapper").  also you are naming the "AlbumCommentTable" as
both the primary table for the AlbumComment class, as well as the
many-to-many table for its comments relationship - it seems like you
are confusing a straight many-to-many relationship with the association
object pattern.  if you are mapping a class to your many-to-many table,
that indicates the association object pattern, and that does not use
the "secondary" argument.  "secondary" is only to describe the
many-to-many table between two mappings where the table is otherwise
not mapped to anything.

also your AlbumCommentTable also has no extra information in it that
would make it worth even having an AlbumComment class.

anyway, if you want AlbumComment as an intermediary association class,
you want this:

class AlbumComment(object):pass
mapper(AlbumComment, AlbumCommentTable,
 'comments':relation(Comment, lazy=False)
)

albumMapper = mapper(Album, AlbumTable,
                    properties={
                                     'images'
:relation(Image,backref='album'),

'comments':relation(AlbumComment),
                                   }
                       )

where above, since AlbumComment represents the many-to-many between
Album and Comment, is the target of "Album"'s "comment" relationship,
and itself contains the mapping to "Comment".

if you want straight many-to-many, ditch the AlbumComment class
altogether and just do this:

mapper(Comment, CommentTable)
mapper(Album, AlbumTable, properties={
  'comments':relation(Comment, secondary=AlbumCommentTable)
})


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