def unique_on(*groups):
 def wrapper(cls):
  cls.__indices__ = getattr(cls, '__indices__', [])
  cls.__indices__.extend([{'key_or_list': [(key, pymongo.ASCENDING) for key in group], 'unique': True} for group in groups])
  return cls
 return wrapper

def unique_on ( * groups ) : def wrapper ( cls ) : cls . __indices__ = getattr ( cls , '__indices__' , [ ] ) cls . __indices__ . extend ( [ { 'key_or_list' : [ ( key , pymongo . ASCENDING ) for key in group ] , 'unique' : True } for group in groups ] ) return cls return wrapper
decorator for subclasses of storedobject .