Suppose I want to create a mapper that exposes a set-like object as an attribute on some mapped class, where the values are (or at least appear to be) not other mapped objects, but rather, simple scalar values like integers or strings. This would be implemented with a table with two columns: a foreign key referring to the parent table, and the value in question. Together they would constitute the table's primary key. Adding something to the set should add a row accordingly, and removing one should delete the row. For example, if the type of data being stored is a string, it would look something like this:
parent.id == 3 parent.things == set(['foo', 'bar', 'baz']) # That means the secondary table has rows (3, 'foo'),(3, 'bar'), (3, 'baz'). parent.things.remove('foo') # Deletes the row (3, 'foo'). parent.things.add('zot') # Inserts a row (3, 'zot'). parent.things.add('zot') # Has no effect since the row already exists. parent.things = set(['bar', 'zot', 'hoorj']) # Deletes the row (3, 'bar') and inserts a row (3, 'hoorj') so as to keep # the table in sync with the newly assigned value. That could be trickier # than the rest, I suppose, and I could do without it The point is to use the simple values directly instead of having to explicitly do it through another mapped class (parent.things == set([Thing('foo'), ...]); parent.things.add(Thing('zot')); etc.). In cases where it is indeed a simple value like this, it would be no less expressive, and easier to read and write. So. How might I do this? Thanks. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---