[z3-five] Re: Some problems I found porting Silva views
Philipp von Weitershausen
philipp at weitershausen.de
Tue Jun 22 21:04:35 MEST 2004
Guido Wesdorp wrote:
> Guido Wesdorp wrote:
>
>> 4. (minor one and discussed by faassen on the channel) form vars
>> aren't passed to methods as arguments, so for a request to
>> 'some_method?foo=bar' some_method is called without the 'foo'
>> argument, to get it's value one needs to use something like
>> 'request['foo']'
>>
> Philipp requested an example setup of this problem, I hacked up the
> FiveViewsDemo so it displays nicely what goes wrong. Install the demo,
> go to some folder and add '/test?some_var=some_value' to the URL and
> you'll see that there's no argument for the function (it would actually
> fail if I'd remove the default value from the argument) and that the
> value of some_var can be found in the request.
I've found and fixed the problem after more than an hour spent with pdb,
sources of zope.publisher and ZPublisher and continuously running Five
tests :).
The problem was that mapply was always seeing the __call__ method from
either one of the mixin classes. __call__ accepts *args, **kwargs, so
mapply couldn't introspect and thus pass no parameter.
To fix this, I used a trick: ZPublisher looks for __browser_default__
which can return an alternate name to be called. Using that, mapply
actually finds the actual method and can introspect. Voila.
As a result, we don't really need __call__ anymore except for tests.
ZPublisher doesn't need __call__ as it looks for __browser_default__.
Maybe we can get rid of __call__ (I would prefer that) and adjust the
tests...
Philipp
More information about the z3-five
mailing list