]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
assoc proxy object appends to list automatically [ticket:1351]
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 15 Jun 2009 22:39:45 +0000 (22:39 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 15 Jun 2009 22:39:45 +0000 (22:39 +0000)
doc/build/reference/ext/associationproxy.rst

index 37cee21799798ab8630f023830437b6e1a2a2788..87489a9e86f8864a81bd3e04db846f97d9e179c6 100644 (file)
@@ -177,10 +177,12 @@ relation.
     user = User('log')
     kw1  = Keyword('new_from_blammo')
 
-    # Adding a Keyword requires creating a UserKeyword association object
-    user.user_keywords.append(UserKeyword(user, kw1))
+    # Creating a UserKeyword association object will add a Keyword.
+    # the "user" reference assignment in the UserKeyword() constructor
+    # populates "user_keywords" via backref.
+    UserKeyword(user, kw1)
 
-    # And accessing Keywords requires traversing UserKeywords
+    # Accessing Keywords requires traversing UserKeywords
     print user.user_keywords[0]
     # <__main__.UserKeyword object at 0xb79bbbec>