I make occasional use of alternate collection classes for my
sqlalchemy relationships.  For example, column_mapped_collection.  The
existing collection classes in sqlalchemy.orm.collections work really
well for me; I have a lot of relational data that very naturally
belongs in dicts rather than lists because it makes sense as one thing
indexed or mapped by another.

I find that I often need to add an item to one of these dict-mapped
collections and would rather not have to check whether the key already
exists in the dict.  So I'm doing, essentially:
collection.setdefault(key, []).append(value).

As a matter of syntactic sugar (which alternative collection classes
already are, anyway) I would like to have collection classes backed by
dicts with the capability of python's defaultdict, so that I could
write more simply, and with equivalent results:
collection[key].append(value)

I understand how to create my own collection class which will behave
as desired.  My question is, has anyone already got code for this that
I could borrow rather than reinvent the wheel?  Thanks in advance.  --
Eric

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