vinjvinj ha scritto:
> Say I have a python class defined:
>
> def class User(object):
>     get_calculated_field(self):
>         return self.a_column_in_user_table_1  +
> self.a_column_in_additional_info
>
> user_table = Table('user_table', metadata, autoload=True)
> additional_info = Table('additional_info', metadata, autoload=True)
>
> Now I need to do the following:
>
> 1. Add an additional read only attribute to the User object which is
> calculated from columns on the user_table and additional_info table
>
> 2. Be able to generate a join between a user_table and additional_info
> table and then for each row that is returned by the db, have the User
> object add calculated_field as a read only attribute (by calling the
> function get_calculated_field)
>   
Why  additional_info isn't a property of  user_table  ?

properties = { 'additional_info'      : relation(additional_info),
                      })

so you have:

a = user_table()
a.a_column_in_user_table_1  + a.additional_info.your_column



Glauco

-- 
+------------------------------------------------------------+
                                  Glauco Uri - Programmatore
                                    glauco(at)allevatori.com 
                               
  Sfera Carta Software®      [EMAIL PROTECTED]
  Via Bazzanese,69  Casalecchio di Reno(BO) - Tel. 051591054 
+------------------------------------------------------------+



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to