Am Die, 2002-08-06 um 15.27 schrieb Greg Ward: > On 06 August 2002, Andreas Kostyrka said: > > Well, it always take some definition of magic. If you take the uninited > > CGI perl coder, than the namespace traversal already looks like magic. > > True, but Quixote was written by and for clueful, experienced Python > programmers. Anything that feels like magic to Andrew, Neil, and me is > too magical. Groping through function objects and looking at parameter > names feels like magic to me. Well, based on this, .ptl files are also. Compared with your import hook, my argument parsing method is purest and most conservative python. > (Oh yeah: cvs -d :pserver:anon@cvs.mems-exchange.org:/home/cvs co quixote) password? > Oops, should have kept reading. That sounds reasonable to me -- nice > clean way to allow people like you to hideously pervert Quixote's > simple, obvious model of calling functions. ;-) Well, it's not that obvious. Especially request is a magic opaque object that is wrongly documented. (for example it is NOT a mapping) And it does not provide any support for dealing with CGI parameters. After having written twice def method(self,request): scaling=int(request.form.get("scaling","1")) angle=int(request.form.get("angle","0")) my brain automatically started to refactoring. It is obviously broken, because I have some "complicated" code that is replicated throughout the source, ... The first step would be: def method(self,request): scaling,angle=self.argumentparser(request) Better, but a) slow (because it involves calling an additional function). [but this is debatable, as argument parsing does have also it's overhead.] b) I have to look at a different place in the source to see how the parameters are processed and what the defaults are. So I've arrived at the trivial: def method(self,request,scaling=1,angle=0): ... That does have the same benefits that .ptl templates have: It reuses Python semantic behaviour. And the only magic thing here is the binding of "request". There are even ways around this magic, by defining __builtin__ request/response functions. (functions, because this allows it to be threadsafe.) Andreas