Re: [sqlalchemy] discriminator_on_association example and association proxies

2013-04-03 Thread bruk.habtu
Hey Michael,

Thanks for the speedy response. I went ahead and changed 
my implementation using the table_per_association example and everything 
works great.


On Tuesday, 2 April 2013 16:49:14 UTC-4, Michael Bayer wrote:

 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 bruk@gmail.com javascript: 
 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 sqlalchemy+...@googlegroups.com javascript:.
 To post to this group, send email to sqlal...@googlegroups.comjavascript:
 .
 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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[sqlalchemy] discriminator_on_association example and association proxies

2013-04-02 Thread bruk.habtu
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [sqlalchemy] discriminator_on_association example and association proxies

2013-04-02 Thread Michael Bayer
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 bruk.ha...@gmail.com 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 sqlalchemy+unsubscr...@googlegroups.com.
 To post to this group, send email to sqlalchemy@googlegroups.com.
 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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.