On Jul 28, 2011, at 6:08 PM, neurino wrote:

> Thanks Michael,
> 
> my need is quite easy, no need of complex querying.
> 
> Simply my class represents a Layer and, while quite all layer types 
> (concrete, wood, bricks, etc.) act the same, only one (air) acts in a 
> completely different way.
> 
> With "act" I refer to performing calculations on float attributes, no more.
> 
> So I can simply put in all calc functions separate operations:
> 
>     if self.type == air:
>         #air calcs
>     else:
>         #all others calcs
> 
> or, in a more elegant way, use a Layer subclass named Air.
> 
> I can't create subclasses for all other layers since I don't know them in 
> advance.
> 
> As far as I understand I have to go with first solution at the moment, right?

probably, there's an old event for this called create_instance (1) that was 
meant for this a long time ago but I don't know what kinds of caveats it has 
with modern usage.   polymorphic_on=callable is ticket #1131 (2), note it is 
very old and the code examples there are out of date.


1: 
http://www.sqlalchemy.org/docs/orm/events.html#sqlalchemy.orm.events.MapperEvents.create_instance
2: http://www.sqlalchemy.org/trac/ticket/1131

> 
> 
> 
> On Thu, Jul 28, 2011 at 11:38 PM, Michael Bayer <mike...@zzzcomputing.com> 
> wrote:
> column_property()
> 
> 
> -- 
> 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 
> sqlalchemy+unsubscr...@googlegroups.com.
> 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 sqlalchemy@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