Dnia 2009-10-02, Pt o godzinie 10:49 -0400, Michael Bayer pisze: > Tefnet Developers wrote: > > > > Hi, > > > > I need to get a single event at an extension in case of such operation: > > > > obj.colAttr = [x, y, z] > > > > right now I will receive: > > extension.remove(...) for each value currently in colAttr > > extension.append(...) for x, y and z. > > > > what I need is something like: > > > > extension.replace(oldvalues, values) with two lists or something like > > that. > > > > .... > > > > What is the proper way to achieve this?
The problem is that we want it to be as transparent as possible (should look like normal list). so.. > > if it were me, I'd just constrain access to a set of methods, such as: > > def set_col_attr(*values) We don't like polluting our namespace with useless get/set_col_attr etc... > > But if that's too simple and straightforward (sarcasm), if you want to > catch coarse-grained get/set events on a collection attribute you need > to > create your own descriptor, with the descriptor/synonym approach > described > at http://www.sqlalchemy.org/docs/05/mappers.html#using-descriptors. > That way your own descriptor can marshal access to/from the actual > attribute. with descriptors it will be a problem with .append .remove methods (afaik descriptor will give us only set/get/del) > As for events on the collection itself you can still use > attributeextension or alternatively a custom collection class. > We wanted to create custom event for our attributeextension but we don't know how to pass our impl_class to attributes.register_attribute_impl so that we could use our extended CollectionAttributeImpl (with modified _set_iterable). Could you suggest the best way to pass our CollectionAttributeImpl to register_attribute_impl or maybe you can modify SQLA and allow to pass impl_class like it is done right now with collection_class. Regards, Tomasz Jezierski Tefnet www.tefnet.pl --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
