[PEAK] Enumeration instances --> values
Erik Rose
psucorp at grinchcentral.com
Sun Mar 20 16:58:01 EST 2005
I'm evaluating PEAK's domain modeling machinery for a project at work
and have run into a question that's got me stumped. I have this
Enumeration:
class HatColor(Enumeration):
red = model.enum('REDX')
vermillion = model.enum('VERM')
I also have a model that uses it and a mostly-finished toy DM that will
pull that model in and out of an RDBMS. My trouble is that I want to
store the four-letter codes 'REDX' and 'VERM' in the DB but can't find
a way to map from HatColor.red back to 'REDX'. The bulletins example
punts and just shoves the string 'HatColor.red' in the DB, which I'd
obviously rather not do. Do I have to build my own machinery for this,
or will the stock framework somehow let me map Enumeration instances
(like HatColor.red) back to values? (I do realize that the main intent
of passing values to enum() is to enable compares between values and
instances, but mapping from instances to values sure would be nice as
well.)
Best regards,
Erik Rose
Code Jockey
Pennsylvania State University
More information about the PEAK
mailing list