Strange. It seems GAE specific issue because
there is no problem on console.
$ python
>>> import lib.vendor.tenjin
>>> from tenjin.helpers import *
>>> to_str(None)
''
Workaround is to add 'lib/vendor' into sys.path.
import sys
sys.path.insert(0, 'lib/vendor')
#sys.path.append('lib/vendor') # not work?
import tenjin
from tenjin.helpers import *
import tenjin.gae; tenjin.gae.init()
This may not a solution for you, but it works well.
>
> The second problem is. Tenjin breaks my handler testing code. It
> just breaks during test load before executing any test code. Saying
> something like:
>
> File "/home/radek/firma/lekarna/src/cl/src/cl-control/trunk/app/
> handlers/user.py", line 21, in <module>
> from tenjin.helpers import *
> File "/home/radek/firma/lekarna/src/cl/src/cl-control/trunk/
> tenjin.py", line 1538, in init
> ver = os.environ.get('CURRENT_VERSION_ID').split('.')[0]
> AttributeError: 'NoneType' object has no attribute 'split'
>
>
> I'm so completely lost, that I'm now searching internet to learn how
> the import internaly works.
>
This is because environment variable $CURRENT_VERSION_ID is missing
on testing environment.
Workaround is to set dummy value before tenjin.gae.init().
import os
os.environ['CURRENT_VERSION_ID'] = '1.1'
import tenjin.gae; tenjin.gae.init()
--
regards,
makoto kuwata
Congratulation.
My code do work with:
sys.path.insert(0, 'lib/vendor')
but doesn't with:
sys.path.append('lib/vendor') # your solution
Hmm. Strange.
--
regards,
makoto kuwata
I' sorry. In this case, we should use setdefault().
import os
os.environ.setdefault('CURRENT_VENDOR_ID', '1.1')
On Tue, Feb 8, 2011 at 8:17 PM, Radek <radek....@gmail.com> wrote:
>
> But I will propose to solve this problem with the third variant as in
> example, by using the default parameter of os.environ.get method. If
> you change the os.environ.get as in the example, no other setting will
> be necesary.
Yes, that's right. I'll change code in the next release.
Thank you.
--
regards,
makoto kuwata