def set_up_storage(schemas, storage_class, prefix='', addons=None, **kwargs):
 _schemas = []
 _schemas.extend(schemas)
 for addon in (addons or []):
  _schemas.extend(addon.models)
 for schema in _schemas:
  collection = '{0}{1}'.format(prefix, schema._name)
  schema.set_storage(storage_class(db=database, collection=collection, **kwargs))
  for index in getattr(schema, '__indices__', []):
   database[collection].ensure_index(**index)

def set_up_storage ( schemas , storage_class , prefix = '' , addons = None , ** kwargs ) : _schemas = [ ] _schemas . extend ( schemas ) for addon in ( addons or [ ] ) : _schemas . extend ( addon . models ) for schema in _schemas : collection = '{0}{1}' . format ( prefix , schema . _name ) schema . set_storage ( storage_class ( db = database , collection = collection , ** kwargs ) ) for index in getattr ( schema , '__indices__' , [ ] ) : database [ collection ] . ensure_index ( ** index )
setup the storage backend for each schema in schemas .