[storm] separating logic from table declarations

Brad Allen ballen at zeomega.com
Wed Feb 10 23:27:59 GMT 2010


Hello,

Has anyone implemented in Storm an useful approach to separating application
logic from the __storm_table__ classes (which I usually call 'entity'
classes)? For purposes of this discussion, I'll use the word 'model' to
describe classes which contain the app logic but which operate on the entity
classes.

After spending some time writing custom code to map entity attributes to our
'model' classes, we hit a brick wall trying to use store.find, which always
returned an instance of the entity (the original __storm_table__ object)
instead of the 'model' class we desired. Changing the cls_info.cls attribute
led to another brick wall, the Property base class raising a
RuntimeError("Property used in an unknown class") because the id of the
model and the entity class didn't match.  It almost seems like the design of
Storm actively discourages this kind of dynamic mapping of property
attributes to other classes.

We ended up using inheritance, with model classes inheriting from entity
classes. This is less than ideal, especially because Reference and
ReferenceSet don't bridge between the base class and the subclass. We had to
recreate all the references in the model classes, and in many cases create
model 'stub' classes where we would prefer to just use the entity classes.

SQLAlchemy has a feature for mapping 'table' object attributes into
arbitrary classes; is it reasonable to add the same kind of functionality to
Storm?

Brad Allen
Architect, Integration Services
ZeOmega
3010 Gaylord Parkway, Suite 210
Frisco, TX 75034
www.zeomega.com
Proven.  Progressive.  Partner.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/storm/attachments/20100210/d3571c1b/attachment.htm 


More information about the storm mailing list