|
From: Brian Z. <bri...@ya...> - 2001-02-13 05:36:25
|
Hi Robert and list,
----- Original Message -----
From: "Robert W. Bill" <rb...@di...>
To: "Brian Zhou" <bri...@ya...>
Cc: <jyt...@li...>
Sent: Monday, February 12, 2001 11:46 PM
Subject: Re: [Jython-dev] jython servlet init() override problem
> Hi Brian,
>
> On Mon, 12 Feb 2001, Brian Zhou wrote:
> > If I write:
> >
> > def init(self):
> > # do something
> > pass
> >
> > I got: TypeError: init() too many arguments; expected 1 got 2
>
> This is referring to the line "def init(self):". PyServlet uses
> 'servlet.init(getServletConfig());', so this is expected. Using the
> parameterless init() is impossible as is.
>
I see. Is that because
HttpServlet.init(self)
HttpServlet.init(self, config)
are difficult to differentiate in jython? I guess it's difficult, but still
possible to do. Unlike
TestClass.m(self, aString)
TestClass.m(self, aFloat)
which is understandably impossible.
> > > If I write:
> >
> > def init(self, config):
> > javax.servlet.http.HttpServlet.init(self, config) # line 14, want
> > to do super.init(config) here
> > # do something
> > pass
> >
> > I got:
> > line 14, in init
> > TypeError: init() not enough arguments; expected 2 got 1
>
> This error is referring to
> "javax.servlet.http.HttpServlet.init(self,config)" not the same
> "def init" line as above.
>
> I thought it might help to point out that the two errors are
> unrelated.
>
> If PyServlet invoked the parameterless init "servlet.init();" on the
> Jython class, then it seems likely that getInitParameters and
> getInitParameterNames still work, and the config would be available
> with getServletConfig. If that works, would people be ok with pre-2.1
> servlet being out of luck?
>
> -Robert
>
Just tried using servlet.init() in PyServlet, it broke snoop.py and threw
NullPointerException. I guess the parmeterless HttpServlet.init() is only
meant to be overriden or be called by HttpServlet.init(config).
The question now becomes: why "HttpServlet.init(self, config)" on line 14
got TypeError? Isn't this the way python code calls super.method()?
Regards,
/Brian
|