From 36f2ff879a8726a86c7bab87ceec4657dbbf93b6 Mon Sep 17 00:00:00 2001
From: Christophe Simonis <chs@openerp.com>
Date: Fri, 7 Mar 2014 16:14:31 +0100
Subject: [PATCH] [FIX] web: use jinja2.FileSystemLoader instead of
 PackageLoader on windows

bzr revid: chs@openerp.com-20140307151431-5k24u6lnlypv1s64
---
 addons/web/controllers/main.py | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index a9f56a2099c6..43b109560a88 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -14,6 +14,7 @@ import hashlib
 import os
 import re
 import simplejson
+import sys
 import time
 import urllib2
 import zlib
@@ -37,10 +38,14 @@ from openerp.http import request, serialize_exception as _serialize_exception
 
 _logger = logging.getLogger(__name__)
 
-env = jinja2.Environment(
-    loader=jinja2.PackageLoader('openerp.addons.web', "views"),
-    autoescape=True
-)
+if hasattr(sys, 'frozen'):
+    # When running on compiled windows binary, we don't have access to package loader.
+    path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'views'))
+    loader = jinja2.FileSystemLoader(path)
+else:
+    loader = jinja2.PackageLoader('openerp.addons.web', "views")
+
+env = jinja2.Environment(loader=loader, autoescape=True)
 env.filters["json"] = simplejson.dumps
 
 #----------------------------------------------------------
-- 
GitLab