changed template paths in settings (takes into account the theme)
[myslice.git] / myslice / theme.py
diff --git a/myslice/theme.py b/myslice/theme.py
new file mode 100644 (file)
index 0000000..d44b854
--- /dev/null
@@ -0,0 +1,26 @@
+import os
+from myslice.configengine import ConfigEngine
+from myslice.settings import TEMPLATE_DIRS
+
+class ThemeView (object):
+    
+    @property
+    def theme(self):
+        self.config = ConfigEngine()
+        if self.config.myslice.theme :
+            return self.config.myslice.theme
+    
+    @property
+    def template(self):
+        # Load a template from the theme directory if it exists
+        # else load it from the common templates dir
+        print "THEME = ",self.theme
+        print "TEMPLATE = ",self.template_name
+        print "TEMPLATE_DIRS = ",TEMPLATE_DIRS
+        filename = self.theme + '_' + self.template_name
+        print any(os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
+        print (os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS)
+        if any(os.path.exists(os.path.join(d,filename)) for d in TEMPLATE_DIRS):
+            return filename
+        else:
+            return self.template_name