Permalink
Browse files

Some classes where failing to execute its __init__ method because a

Python internal check. The class they inherited from was in a module
that was being reloaded after the main code was parsed, the internal
class identifier changed and thus the interpreter failed to execute
the class constructor. It's kind of a twister issue.

This patch adds a cache that takes care of loading the plug-in and
template modules just once. It's basically fixing the problem from its
root.

git-svn-id: svn://cherokee-project.com/wizards2@6818 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent 6bad606 commit 099effe1d5ada77df15ee010b42178b8c350808f @alobbs alobbs committed Aug 19, 2011
Showing with 19 additions and 8 deletions.
  1. +19 −8 Wizard2.py
View
27 Wizard2.py
@@ -262,17 +262,28 @@ def _Check_File_Exists (self, filename):
return errors
+_modules = {}
def Load_Module (path):
- tmp = path.split('/')
- dsc = tmp[-1].replace('.py','')
+ global _modules
+ if not path in _modules:
+ tmp = path.split('/')
+ dsc = tmp[-1].replace('.py','')
- php_mod_path = os.path.realpath (__file__ + '/../wizards/' + path)
- return CTK.load_module_pyc (php_mod_path, dsc)
+ php_mod_path = os.path.realpath (__file__ + '/../wizards/' + path)
+ _modules[path] = CTK.load_module_pyc (php_mod_path, dsc)
+ return _modules[path]
+
+
+_templates = {}
def Load_Template (path):
- tmp = path.split('/')
- dsc = tmp[-1].replace('.py','')
+ global _templates
+ if not path in _templates:
+ tmp = path.split('/')
+ dsc = tmp[-1].replace('.py','')
+
+ php_mod_path = os.path.realpath (__file__ + '/../templates/' + path)
+ _templates[path] = CTK.load_module_pyc (php_mod_path, dsc)
- php_mod_path = os.path.realpath (__file__ + '/../templates/' + path)
- return CTK.load_module_pyc (php_mod_path, dsc)
+ return _templates[path]

0 comments on commit 099effe

Please sign in to comment.