Can anyone figure out my problem [Python]
<p>I have been trying to debug the below python cgi code but doesn't seems to work. When i try in new file it these three lines seems to work</p>

<pre><code>filename=unique_file('C:/wamp/www/project/input.fasta')
prefix, suffix = os.path.splitext(filename)
fd, filename = tempfile.mkstemp(suffix, prefix+"_", dirname)
</code></pre>

<p>But, when i try like this way then i get error unique_file is not define >>></p>

<pre><code>form=cgi.FieldStorage()
i=(form["dfile"].value)
j=(form["sequence"].value)
if (i!="" and j=="" ):
    filename=(form["dfile"].filename)
    (name, ext) = os.path.splitext(filename)
    alignfile=name + '.aln'
elif(j!="" and i==""):
    filename=unique_file('C:/wamp/www/project/input.fasta')
    prefix, suffix = os.path.splitext(filename)
    fd, filename = tempfile.mkstemp(suffix, prefix+"_", dirname)
    file = open(filename, 'w')
    value=str(j)
    file.write(value)
    file.close()
    (name, ext) = os.path.splitext(filename)
    alignfile=name + '.aln'
</code></pre>

<p>What i am trying to do is check two options from form:- Fileupload and textarea. If fileupload is true then there is nothing to do except separating file and its extension. But when textarea is true then i have to generate unique file name and write content in it and pass filename and its extension.</p>

<p>Error i got is...</p>

<pre><code>type 'exceptions.NameError'&gt;: name 'unique_file' is not defined
  args = ("name 'unique_file' is not defined",)
  message = "name 'unique_file' is not defined"
</code></pre>

<p>Any suggestions and corrections are appreciated</p>

<p>Thanks for your concern</p>
