On Sep 14, 2010, at 5:03 PM, A.M. wrote:
> Hello,
>
> I have a schema like this:
>
> Image
> *id
> *name
>
> Metadatakey
> *id
> *exifkey
> *name
>
> Metadata
> *id
> *image_id -> Image
> *metadatakey_id -> Metadatakey
> *value
>
> Is there any way for me to create a dictionary-based collection to represent
> the image metadata as Metadatakey.name=>Metadata.value ? After a cursory
> look, it seems that the default collection mappers work only for keys and
> values in the same table, no?
give MetaData a relationship to MetaDataKey, put a "key" descriptor:
@property
def key(self):
return self.meta_data_key.name
then use attribute_mapped_collection giving "MetaData.key" as the "key"
attribute.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.