sorry, fixed patch --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Index: orm/collections.py =================================================================== --- orm/collections.py (revision 3333) +++ orm/collections.py (working copy) @@ -647,35 +648,32 @@ # ensure all roles are present, and apply implicit instrumentation if # needed - if 'appender' not in roles or not hasattr(cls, roles['appender']): + for rolename,eventname in dict( + appender='fire_append_event', + remover ='fire_remove_event', + iterator=None, + ).iteritems(): + roler = roles.get( rolename, None) + if not rolename or not hasattr(cls, roler): + typename = cls.__name__ raise exceptions.ArgumentError( - "Type %s must elect an appender method to be " - "a collection class" % cls.__name__) - elif (roles['appender'] not in methods and - not hasattr(getattr(cls, roles['appender']), '_sa_instrumented')): - methods[roles['appender']] = ('fire_append_event', 1, None) - - if 'remover' not in roles or not hasattr(cls, roles['remover']): - raise exceptions.ArgumentError( - "Type %s must elect a remover method to be " - "a collection class" % cls.__name__) - elif (roles['remover'] not in methods and - not hasattr(getattr(cls, roles['remover']), '_sa_instrumented')): - methods[roles['remover']] = ('fire_remove_event', 1, None) - - if 'iterator' not in roles or not hasattr(cls, roles['iterator']): - raise exceptions.ArgumentError( - "Type %s must elect an iterator method to be " - "a collection class" % cls.__name__) + "Type %(typename)s must elect an %(role)s method to be " + "a collection class" % locals() ) + elif (eventname and + roler not in methods and + not hasattr(getattr(cls, roler), '_sa_instrumented')): + methods[ roler] = ( eventname, 1, None) # apply ad-hoc instrumentation from decorators, class-level defaults # and implicit role declarations