On Nov 12, 2008, at 3:31 PM, Faheem Mitha wrote:
> > 1) First, a typo. In section "Simplifying Association Object > Relations": "Because the proxies are backed a regular relation > collection" should have the word "by" or similar following "backed". indeed. > > > 2) In section "Building Complex Views" > > print broker.holdings[stock].shares > # 10 > > Isn't holdings[stock] the share value? Ie. shouldn't this just be > > print broker.holdings[stock] > > ? im going to go out on a limb here since I did not write these docs and suggest it should say: broker.by_stock[stock] = Holding(broker, stock, 10) print broker.by_stock[stock].shares to illustrate non-association proxy usage, before the next blurb that describes the association proxy usage. > 3) The title "Simplifying Association Object Relations" appears twice > in > http://www.sqlalchemy.org/docs/05/ > plugins.html#plugins_associationproxy oh, this is an indexing issue in the file....many fixes to be made (note to fixers - needs [EMAIL PROTECTED] ) > 4) A more general question: > > I'm having difficulty parsing the last three lines in the itemized > list in Section "associationproxy". > > "The relation is inspected ..." through "A creator funcion can be > used..." > > In particular, I'm having difficulty understanding the point of the > creator function in association_proxy. I see where creator functions > are > defined (two places), but don't see them being used. the association proxy manages an association relation across three objects, such as: A->B->C when you say something along the lines of: A.someelement = C the "B" is created implicitly by the association proxy. The creator function is used to customize the process of creating the B instance. > 5) An even more general comment: > > There are two discussions on mapping association objects. One of them > is in the mapper docs > (http://www.sqlalchemy.org/docs/05/mappers.html#advdatamapping_relation_patterns_association > > ) > and uses a one-many and many-one relation. The second is in the docs > for association proxy > (http://www.sqlalchemy.org/docs/05/plugins.html#plugins_associationproxy_building > > ), > two examples in "Simplifying Association Object Relations" and > "Building Complex Views", and uses association_proxy. > > It looks like either of these approaches can be used to initialize and > update the db. It might be helpful if these two could be connected > somehow. Perhaps a see also in the respective sections? I do see a > "To > enhance the association object pattern such that direct access to the > Association object is optional, SQLAlchemy provides the > associationproxy." > in > http://www.sqlalchemy.org/docs/05/mappers.html#advdatamapping_relation_patterns_association > > , > but it seems like you could just use the association_proxy setup > described > by itself, and it would suffice. The version in > http://www.sqlalchemy.org/docs/05/mappers.html#advdatamapping_relation_patterns_association > says explicitly that this is the way to go - doesn't clearly point to > alternatives. If I understand the question to mean, "why illustrate two ways", its because the main mapping docs are describing a basic relational pattern and contrasting it to what is termed "many to many",which is similar except that many-to-many does not assign any additional information to the association table. Its a core pattern that most non-trivial schemas will need to use. The association proxy OTOH is not necessary in any case, but is strictly a convenience layer used to provide more succinct access in the Python space across an association relation. We don't want people even considering its usage until they have a firm grasp of the association object pattern, hence its treated as an "extra". The association proxy is also not strictly only for use with an association relation - it can also be used to provide direct access to scalars on related objects, for example, such as representing a list of integers or strings. It's really not at all a "relational pattern" and is instead a Python attribute access helper. ticket #1224 is added to address the docs issue. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" 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/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---
