+
+
+# def gridify_list(this_list, num_cols=5):
+# """
+# Generates a list of lists where each sub-list's length depends on
+# the number of columns in the list
+# """
+# grid = []
+
+# # Figure out how many rows we should have
+# num_rows = int(ceil(float(len(this_list)) / num_cols))
+
+# for row_num in range(num_rows):
+# slice_min = row_num * num_cols
+# slice_max = (row_num + 1) * num_cols
+
+# row = this_list[slice_min:slice_max]
+
+# grid.append(row)
+
+# return grid
+
+
+# def gridify_cursor(this_cursor, num_cols=5):
+# """
+# Generates a list of lists where each sub-list's length depends on
+# the number of columns in the list
+# """
+# return gridify_list(list(this_cursor), num_cols)
+
+
+def render_404(request):
+ """
+ Render a 404.
+ """
+ return render_to_response(
+ request, 'mediagoblin/404.html', {}, status=400)
+
+def delete_media_files(media):
+ """
+ Delete all files associated with a MediaEntry
+
+ Arguments:
+ - media: A MediaEntry document
+ """
+ for listpath in media['media_files'].itervalues():
+ mg_globals.public_store.delete_file(
+ listpath)
+
+ for attachment in media['attachment_files']:
+ mg_globals.public_store.delete_file(
+ attachment['filepath'])