On Apr 7, 2011, at 4:36 PM, Luca Lesinigo wrote:

> Hello there. I'm using SA-0.7 to develop an application that should
> help me manage my company's services.
> 
> A central concept here is the order, it could be a service (like one
> year of web hosting) or a physical item (like a pc we sell). So far I
> generalized them in two classes: the Order and the ServiceOrder - the
> latter simply inherits the former and adds start and end dates.
> 
> Now I need to add all various kinds of metadata to orders, for
> example:
> - a ServiceOrder for a domain hosting should contain the domain name
> - a ServiceOrder for a maintenance service should contain the service
> level for that service (say, basic or advanced)
> - an Order for a PC we delivered should contain its serial number
> - and so on...
> 
> I could easily add child classes, but that would mean to keep and
> maintain that code forever even after we stop using it (ie, next year
> we stop doing hosting) or when it's not really useful (many things
> will just have some 'metadata' in them like a serial number or similar
> things). I'd also like to avoid having to add code every time we just
> hit something slightly different to manage, when we just have some
> additional data to keep track of.
> I wonder what could be an intelligent approach to such a situation.

why not separate the product from the fact of its being ordered ?  compose 
Order->Product instead of inherit.

As far as variable attributes which you only need to retrieve, never to query 
on, there are many recipes for a "bag" of attributes.    By far the easiest is 
a recipe like JSON type: 
http://www.sqlalchemy.org/docs/core/types.html#marshal-json-strings

More broken out are key/value tables, this is more like your ordertags idea.   
recipes: 
http://www.sqlalchemy.org/docs/orm/examples.html#vertical-attribute-mapping  
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/VersionedMap

-- 
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