Rhett Garber wrote:
>>>
>>> Oh right, sorry:
>>>
>>> class Advertiser(Base):
>>>    __tablename__ = "advertiser"
>>>    id, _id = build_id_column('id', primary_key=True)
>>>    salesperson_id, _salesperson_id =
>>> build_id_column('salesperson_id', foreign_key=ForeignKey("%s.id" %
>>> Salesperson.__tablename__))
>>>    salesperson, _salesperson = build_relation(Salesperson)
>>
>> sorry, that mapping doesn't really make any sense to me.
>>
>>> Where these build_* functions are returning tuple where the first
>>> element is a synonym for the second, which some extra descriptor stuff
>>> on it
>>> to do the obfuscation.
>>
>> right but, you don't define synonyms that way.   Its best to stick with
>> the methods in the documentation.
>>
>
> Sorry if I'm not explaining myself quite clearly. build_id_column() is
> doing exactly what the docs are saying to do,
> just trying to abstract out that pattern since it will be used on
> every single object in our system, often for multiple cols.

OK.  So the issue is you'd like to use declarative, specify "id =
something()", and "_id" is generated automatically ?

It depends on specifics.  If the specific is, you have lots of classes,
and they all just need to have "id"/"_id", you should use a mixin that
defines those two elements, which is a newly supported capability in 0.6.

If OTOH you have lots of classes and each one can have any number of
columns of a variety of names, your best bet is to create a metaclass
which generates the "private" version of each attribute as needed.  This
metaclass can be a subclass of DeclarativeMeta, or if not you just need to
call instrument_declarative() for each class you'd like mapped, after the
desired attributes are configured.


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

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

Reply via email to