# HG changeset patch # User Atul Varma # Date 1204732110 21600 # Node ID b7ef29e851b477f57a14fc99988d0eb6aaff103e # Parent f19c2a2987cc1e427a2ccfebb1c92a446f8d192c Added documentation. diff -r f19c2a2987cc -r b7ef29e851b4 PersonasBackend/personas/views.py --- a/PersonasBackend/personas/views.py Wed Mar 05 09:37:45 2008 -0600 +++ b/PersonasBackend/personas/views.py Wed Mar 05 09:48:30 2008 -0600 @@ -31,7 +31,17 @@ context_instance = RequestContext(request) ) -def _rename_file( filedict, persona ): +def _rename_file( filedict, persona=None ): + """ + Attempts to find a better name for an uploaded persona image + represented by the given HttpRequest file info dictionary and an + optional models.Persona object. + + Uploaded files are named by the submitter, and could have names + that are completely meaningless to us, so we want to try to rename + them to something that makes more sense to us. + """ + import os import time @@ -39,7 +49,9 @@ # file after the commit is made or something. origExt = os.path.splitext( filedict["filename"] )[1] - # TODO: Normalize origExt somehow? + + # TODO: Normalize/validate origExt somehow? + if persona: filename = "persona_%d_rev_%d%s" % ( persona.id,