This might be familiar to some, there is a calling style on relation
() where it can, in one step, create a mapper and a relation to that
mapper. This conflation of functionality, created with the goal of
"less typing", leads to a very common error:
Address.mapper = mapper(Address, addresses)
User.mapper = mapper(User, users, properties = {
'addresses' : relation(Address, addresses)
})
which creates two different mappers for Address, often unrealized by
the user (it can easily be confused with, "get me the mapper that
relates Address to addresses"). The origin of this calling style is
when i first wrote the mapper package I was thinking on the select-
side only, so the concept of the "primary mapper", that is the mapper
which defines the relationships used by objectstore.commit(), was not
really conceived yet, so the above error was not as big a deal. But
since it is now important that the developer is aware of the "primary
mapper", the above calling style to relation() will raise a
descriptive ValueError.
So now, the two forms of relation() are:
relation(mapper, **kwargs)
relation(class, **kwargs)
where the second form will fetch the "primary mapper" for the given
class and use that as the argument; this form is most useful for self-
referring mappers, since the "primary mapper" fetch is not performed
until the mapper enclosing the relation(), typcially the primary
mapper, is created.
This change also has the effect of making the relation() function
simpler, and removes its "multimethod" functionality which at least
one user had commented on.
it also is abiding by that "explicit is better than implicit" idea,
but it would be unwise for me to refer to Python-isms as I probably
break them at least if not more often than I follow them...
- mike
-------------------------------------------------------
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://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users