Manera, Villiam
vmanera at manord.com
Wed Jun 22 04:15:17 EDT 2005
No may change are in subclass of Servlet,I stil have the version 1.1.5 from 08/09/2004 patched as you suggest: I see your problem. While I don't think I want to add this to the mainstream distribution, it's actually quite simple (so, perhaps I should just shut up and do it!). You can apply the patch attached below. It adds a keep_blank_values attribute with a default of 0 to Servlet, so unless you change something in a subclass, servlets will behave exactly as they do now. To get the behaviour you want, set keep_blank_values to 1 in a subclass, eg: MyServlet(HTMLPage): keep_blank_values = 1 ... content_type = None auth_realm = 'Unspecified' reusable = True + keep_blank_values = 0 use_session = False session = None session_timeout = 60 * 30 # 30 minutes ..... ! self.form = util.FieldStorage(self.req, self.keep_blank_values) -------------------------------------------- I noted that in the 1.1.6 version this in still missing and I will patch it myself. Now for debug I changed: try: if not issubclass(klass, Servlet): raise ValueError except: raise ValueError, ('%s is not a subclass of Servlet (in %s) code: %s' % (basename, fname, str(code))) With the code displayed I hope to find something more... Villiam -----Messaggio originale----- Da: Daniel Popowich [mailto:dpopowich at comcast.net] Inviato: martedì 21 giugno 2005 20.36 A: Manera, Villiam Cc: mod_python at modpython.org Oggetto: Re: [mod_python] Loading servlet problem Manera, Villiam writes: > I noted a funny behavior on loading servlet, sometime work sometime : > > File "/usr/local/lib/python2.4/site-packages/mod_python/servlet.py", > line 1345, in get_servlet > klass, servlets = self.__load_servlet(filename) > > File "/usr/local/lib/python2.4/site-packages/mod_python/servlet.py", > line 1276, in __load_servlet > raise ValueError, ('%s is not a subclass of Servlet (in %s)' > > ValueError: menu is not a subclass of Servlet (in > /discoe/script/cgi/bulgaria/bulgaria_menu.py/menu.mps) > > Obviously menu.mps is subclass od Servlet. > > > This happened sometime, on different servlet ???? > > > If I restart apache all work fine for some time... Have you modified servlet.py? If so and PythonAutoReload is "on" then servlet.py is being reloaded by the python interpreter which will create a new Servlet class with different identifier than the one cached by the servlet manager in servlet.py. That's why restarting apache fixes your problem: you get fresh copies of everything in new python interpreters. To avoid this: 1. You really shouldn't change servlet.py. Put modifications/extensions in subclasses...the power of OO and all... 2. In development mode, I configure my prefork apache with: MaxRequestsPerChild 1 Sure, it's a performance hit, but you NEVER have to deal with stale python module importing issues and you don't have to litter your code with special-case importing code, etc. Cheers, Daniel Popowich ----------------------------------------------- http://home.comcast.net/~d.popowich/mpservlets/
|