Gaetan de Menten wrote:

> We could, of course, but I find it more logical this way as for me,
> when you go "via" something, you end up somewhere else. Here, on a
> field statement, you end up "on" the attribute itself.

Okay, I can see your point.  I still prefer standardizing on "via" but I
can live with the way it is now, so lets stick with it.

Now, another question.  I was thinking it would be nice if we could
even have the `has_many(through=..., via=...)` handle chaining together
collections for us as well, like so:

     class Company(Entity):
         has_field('name', Unicode)
         has_many('contacts', of_kind='Contact', inverse='company')
         has_many('users', through='employments', via='user',
                  creator=lambda user: Employment(user=user))

     class User(Entity):
         has_field('username', Unicode)
         has_many('employments', of_kind='Employment', inverse='user')
         has_many('companies', through='employments', via='company')

         # right now, you have to do this:
         @property
         def contacts(self):
             for company in self.companies:
                 for contact in company.contacts:
                     yield contact

         # wouldn't it be nice if you could do this instead?
         has_many('contacts', through='companies', via='contacts')

     class Employment(Entity):
         has_field('title', Unicode)
         belongs_to('company', of_kind='Company',
                    inverse='employments')
         belongs_to('user', of_kind='User', inverse='employments')

     class Contact(Entity):
         has_field('firstname', Unicode)
         has_field('lastname', Unicode)
         belongs_to('company', of_kind='Company', inverse='contacts')


I am not sure if the AssociationProxy extension handles this, but we
could probably fake it by attaching a property.  What do you think?

--
Jonathan LaCour
http://cleverdevil.org


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to