the Customer.comments attribute proxies through "comment_association" which is 
configured as a scalar.    this should probably be improved in this particular 
recipe, but for starting assignment you need to assign a collection first:

c1 = Customer()
c1.comments = []


I don't ever use "discriminator_on_association", it's the most awkward and 
least efficient recipe; it's only there to show an improvement over what Django 
and Rails do.  In practice, I typically advise table_per_assocation; the use 
case of being able to trace back everything that's "tagged" back to the parents 
polymorphically is not needed much in practice.






On Apr 2, 2013, at 3:45 PM, bruk.habtu <[email protected]> wrote:

> I was attempting to implement the example shown in 
> https://github.com/ContextLogic/sqlalchemy/blob/master/examples/generic_associations/discriminator_on_association.py
> 
> trace: https://gist.github.com/brukhabtu/2294f0873830243845db
> my code: https://gist.github.com/brukhabtu/1423c9825252ddcf85a5
> 
> Customer model inherits CommentMixin. 
> 
> Error occurs when appending to the customer's comments
> 
> customer.comments.append(comment)
> 
> 
> The trace shows that the error happens in associationproxy.py
> 
> return self._scalar_get(getattr(obj, self.target_collection))
> 
> obj is a Customer model object and self.target_collection is a string with 
> the value 'comment_association'. 
> 
> The attribute exists but is set to None. 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to