def _preformat_objects(modules, objects):
 output = {}
 if objects:
  for module in modules:
   output[module.name] = {'module': module, 'label': _(module.title), 'count': 0, 'objects': {}}
   for key in objects:
    if (objects[key]['module'] == module):
     if hasattr(objects[key]['objects'], 'count'):
      output[module.name]['count'] += objects[key]['objects'].count()
     objects[key]['label'] = _(objects[key]['label'])
     output[module.name]['objects'][key] = objects[key]
 return output

def _preformat_objects ( modules , objects ) : output = { } if objects : for module in modules : output [ module . name ] = { 'module' : module , 'label' : _ ( module . title ) , 'count' : 0 , 'objects' : { } } for key in objects : if ( objects [ key ] [ 'module' ] == module ) : if hasattr ( objects [ key ] [ 'objects' ] , 'count' ) : output [ module . name ] [ 'count' ] += objects [ key ] [ 'objects' ] . count ( ) objects [ key ] [ 'label' ] = _ ( objects [ key ] [ 'label' ] ) output [ module . name ] [ 'objects' ] [ key ] = objects [ key ] return output
formats objects returned from get_contact_objects or get_user_objects for a more convenient output and templating .