Daniel Popowich
dpopowich at comcast.net
Fri Sep 3 15:04:53 EDT 2004
Vinj Vinj writes: > >obvious a method is being called: change the value of > METHODCALL at > .the top of servlet.py. This is probably another > > Will this change what is checked for '_call_'. > Eventually, I'll obfuscate the string, but that's not > w arequirement right now. Yes, if you change METHODCALL (or if it's an attribute of Servlet and you modify it in a subclass) then your HTML will need to be modified to reflect the change. > >This functionality exists! Check out lesson #17 of > >the tutorial: > > the problem with the above approach is that write_html > is what calls the write_header, write_footer > write_body_parts, etc and if you don't call that you > will have to do all of those manually which does not > seem to be right. So, if a method gets called via a GET or POST what is it you want to change? write_body_parts()? write_content()? My hunch is you can still do the "return True" trick without much headache. Or, assuming all you want to change is write_content, you can do something like this: 1. Create a method, default_write_content, and in prep: def prep(self): HTMLPage.prep(self) self.write_content = self.default_write_content ... 2. For each "_call_" method named NAME, create a NAME_write_content method, eg, if ok_methods_to_call == [foo, bar, baz], then: def foo(self): self.write_content = self.foo_write_content ... def bar(self): self.write_content = self.bar_write_content ... def baz(self): self.write_content = self.baz_write_content ... and each of these methods (foo, bar, baz) should return False or drop off the end (returning None); then the write_content method appropriate for the particular action will be called when write_html is called by respond. If no "_call_" method is called then default_write_content will be used. Hope this helps, Daniel Popowich ----------------------------------------------- http://home.comcast.net/~d.popowich/mpservlets/
|