I'm creating a page containing a form including a <select> field which <options> values are filled from a database query. I would like to cache the result of the query, in order to make the query only once, and therefore speed up the rendering. I really mean once, not once per session.
I though that storing the result of my query in a class variable would solve the problem, but it doesn't.
Ok, I thought that CacheServletClasses = 1 would "freeze" the class as it is when first loaded, but actually, it's just the contrary.
Many thanks to Jason and deelan.
I did my homework and had a look at ServletFactory.py. If CacheServletClasses is set to 0, the PythonServletFactory reloads the module containing the servlet class from file (by calling ImportAsPackage, which calls _importModuleFromDirectory with forceReload set to 1), which means that all dynamically-changed members of the class are lost.
In plain Python, this would be like :
*** file testImp.py ***
class myClass:
data = "From module"
****** file test.py *** import testImp
myInst = testImp.myClass() testImp.myClass.data = "Dynamically changed"
reload(testImp)
print testImp.myClass.data # --> "From module" ***
Cheers,
olivier
------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss
