Hi Michael,

Am Mittwoch, den 27.10.2010, 13:37 -0400 schrieb Michael Bayer:


> Configuration is too unwieldy ?   Since you're using declarative ,
> just using @declared_attr would give you access to the class:

Nice one. I missed classproperty and declared_attr so far.

> def make_ordered_list(key, pk, type_):
>     @declared_attr
>     def go(cls):
>         class Name(Base):
>             __tablename__ = "%s_names" % key
>             rel_id = Column("related_id", Integer, ForeignKey(pk), 
>                             primary_key=True, index=True)
>             position = Column("position",  Integer)
>             value = Column("value", type_, primary_key=True)
>             def __init__(self, value):
>                 self.value = value
>         private_key = "_" + key
>         
>         setattr(cls, key, association_proxy(private_key, "value"))

Now that's a hefty trick, updating the class when reading the property.
I think this should be protected against running twice!? Or does the ORM
mapper do this for us?
 
> if you wanted to get rid of saying "_names", you need to create
> something that is added after the fact:

Yep, or add a placeholder into the class and have the mapper replace it
by the real thing. I'll look into that!

Thanks for all you support wrt. SQLAlchemy, I am always impressed how
you can come up with helpful answers in virtually no time. I tried the
Donate button on SA.org so you can have a beer on my expenses :-)

Greetings, Torsten


-- 
DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH
Torsten Landschoff

Office Dresden
Tel: +49-(0)351-4519587
Fax: +49-(0)351-4519561

mailto:torsten.landsch...@dynamore.de
http://www.dynamore.de

Registration court: Mannheim, HRB: 109659, based in Karlsruhe,
Managing director:  Prof. Dr. K. Schweizerhof, Dipl.-Math. U. Franz

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to