title: Problems importing gluon.html from outside web2py
body: <p>I want to try to code some gluon-derived components (<code>web2py</code> html helpers), outside from <code>web2py</code>. This way I can test components on the command line, and generate simple html files which I can analize before integrating them with the complete <code>web2py</code> application stack. This speeds up my development cycle, since I can concentrate on finetuning the HTML of the component without worrying about any other issues (redeploys, databases, ...). Fast and easy: prepare a web2py component with <code>gluon.html</code> helpers, see if the HTML generated looks good, and <em>then</em> use it from within <code>web2py</code>.</p>
  
  <p>The test has been mostly successful. I just had to:</p>
  
  <pre><code>from   gluon.html                import A, TABLE, DIV, SPAN, THEAD, TR, TH, TBODY, URL, H1
  
  def T(txt):
      return txt
  
  def my_simple_component(title):
      return H1(T(title))
  
  def test():
      print my_simple_component('Hello')
  </code></pre>
  
  <p>Which produces the expected output:</p>
  
  <pre><code>$ python test_web2py_components.py
  &lt;h1&gt;Hello&lt;/h1&gt;
  </code></pre>
  
  <p>(I do not care about <code>T</code> in my tests. And for my any test <code>URL</code> that I want to use, I just pass a fake application / controller / function.)</p>
  
  <p>The only problem that I have found is that I need to have a symbolic link to <code>web2py</code> for the <code>gluon.html</code> import to work, even though gluon is on the PYTHONPATH.</p>
  
  <pre><code>ln -s /install_dir/web2py/gluon/ .
  </code></pre>
  
  <p><strong>Is there a way to import gluon components without having that extra link?</strong></p>
  
  <p>Consider that during the test phase my components are outside of the web2py application tree.</p>
  
  <p>This is the error I get:</p>
  
  <pre><code>Traceback (most recent call last):
    File "lib_test1.py", line 4, in &lt;module&gt;
      from   gluon.html                import A, TABLE, DIV, SPAN, THEAD, TR, TH, TBODY, URL
    File "/install_dir/web2py/gluon/__init__.py", line 15, in &lt;module&gt;
      from globals import current
    File "/install_dir/web2py/gluon/globals.py", line 24, in &lt;module&gt;
      from serializers import json, custom_json
    File "/install_dir/web2py/gluon/serializers.py", line 11, in &lt;module&gt;
      from languages import lazyT
    File "/install_dir/web2py/gluon/languages.py", line 264, in &lt;module&gt;
      PLURAL_RULES = read_possible_plurals()
    File "/install_dir/web2py/gluon/languages.py", line 250, in read_possible_plurals
      for pname in os.listdir(pdir):
  OSError: [Errno 2] No such file or directory: '/current_dir/gluon/contrib/rules'
  </code></pre>
  
  <p>(Do not consider <code>install_dir</code> and <code>current_dir</code>: they have been introduced for this question)</p>