title: Reading from a text file web2py
body: <p>I'm having an issue with web2py. I have a text file called defVals.txt that's in the modules folder. I try to read from it, using <code>open("defVals.txt")</code> (in a Module in the same director as defVals.txt), but I get the error:</p>
  
  <pre><code>Traceback (most recent call last):
   File "/home/jordan/web2py/gluon/restricted.py", line 212, in restricted
     exec ccode in environment
  File "/home/jordan/web2py/applications/randommotif/controllers/default.py", line 67,     in &lt;module&gt;
   File "/home/jordan/web2py/gluon/globals.py", line 188, in &lt;lambda&gt;
  self._caller = lambda f: f()
  File "/home/jordan/web2py/applications/randommotif/controllers/default.py", line 13, in index
    defaultData = parse('defVals.txt')
  File "applications/randommotif/modules/defaultValParser.py", line 6, in parse
   lines = open(fileName)
  IOError: [Errno 2] No such file or directory: 'defVals.txt'
  </code></pre>
  
  <p>What am I doing wrong? Where should I place defVals.txt</p>
  
  <p>I'm using Ubuntu 12.10</p>
  
  <p>Thanks,</p>
  
  <p>Jordan</p>
  
  <p>Update:</p>
  
  <p>This is the source code to defaultValParser.py:</p>
  
  <pre><code>import itertools
  import string
  import os
  from gluon import *
  from gluon.custom_import import track_changes; track_changes(True)
  
  #this returns a dictionary with the variables in it.
  def parse(fileName):
      moduleDir = os.path.dirname(os.path.abspath('defaultValParser.py'))
      filePath = os.path.join(moduleDir, fileName)
      lines = open(filePath, 'r')
      #remove lines that are comments. Be sure to remove whitespace in the beginning and end of line
      real = filter(lambda x: (x.strip())[0:2] != '//', lines)
      parts = (''.join(list(itertools.chain(*real)))).split("&lt;&gt;")
      names = map(lambda x: (x.split('=')[0]).strip(), parts)
      values = map(lambda x: eval(x.split('=')[1]), parts)
      return dict(zip(names, values))
  </code></pre>
  
  <p>It works fine if I import it and call it from a terminal (provided I comment out the gluon imports), but if I call it from a web2py controller, it fails completely:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/jordan/web2py/gluon/restricted.py", line 212, in restricted
     exec ccode in environment
    File "/home/jordan/web2py/applications/randommotif/controllers/default.py", line 71, in &lt;module&gt;
    File "/home/jordan/web2py/gluon/globals.py", line 188, in &lt;lambda&gt;
    self._caller = lambda f: f()
    File "/home/jordan/web2py/applications/randommotif/controllers/default.py", line 17, in index
    defaultData = parse('defVals.txt')
    File "applications/randommotif/modules/defaultValParser.py", line 6, in parse
   IOError: [Errno 2] No such file or directory: 'defVals.txt'
  </code></pre>