Re: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Jeffrey P Shell
On 4/11/02 3:14 PM, "Geoffrey Talvola" <[EMAIL PROTECTED]> wrote: > Jeffrey Shell wrote: >> Be wary of these attributes - they can grow like wildfire. >> Almost every >> large Python application I've worked on where people started using >> class-like attributes in this manner has grown into a qui

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Ian Bicking
On Thu, 2002-04-11 at 15:14, Jeffrey P Shell wrote: > The Interfaces package that Zope uses uses the __implements__ attribute. A > benefit is that it's a single common attribute that can be checked. Even if > Webware doesn't sign on to using something like Interfaces, it might be > worth to use

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Ian Bicking
On Thu, 2002-04-11 at 12:37, Chuck Esterbrook wrote: > I agree, but then it seems we should just put _isServlet=1 in > Servlet.py and skip the issubclass() call: > > if not getattr(theClass, '_isServlet', 0): > raise ... issubclass handles the dual-import problem, while _is

RE: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Geoffrey Talvola
Jeffrey Shell wrote: > Be wary of these attributes - they can grow like wildfire. > Almost every > large Python application I've worked on where people started using > class-like attributes in this manner has grown into a quite a mess, > sometimes with two or three of these attributes that > ul

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Jeffrey P Shell
On 4/11/02 11:37 AM, "Chuck Esterbrook" <[EMAIL PROTECTED]> wrote: > > I agree, but then it seems we should just put _isServlet=1 in > Servlet.py and skip the issubclass() call: > > if not getattr(theClass, '_isServlet', 0): > raise ... Be wary of these attributes - they can grow like wildfire

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Chuck Esterbrook
On Thursday 11 April 2002 08:01 am, Geoffrey Talvola wrote: > I would propose a similar solution, but without methods.  Use this as > the test in ServletFactory in place of the current assertion: > > # A class is useable as a Servlet if it is derived from > Servlet OR if it contains an _is

RE: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Geoffrey Talvola
[EMAIL PROTECTED] wrote: > On Thu, Apr 11, 2002 at 11:01:08AM -0400, Geoffrey Talvola wrote: > > class MyFakeServlet: > > _isServlet = 1 > > ... > > > > The Servlet class itself doesn't need to change at all. > > > > My rationale is that this is a fixed property of a > particular class,

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Mike Orr
On Thu, Apr 11, 2002 at 11:01:08AM -0400, Geoffrey Talvola wrote: > class MyFakeServlet: > _isServlet = 1 > ... > > The Servlet class itself doesn't need to change at all. > > My rationale is that this is a fixed property of a particular class, so it > should be a class attribute, ra

RE: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Edmund Lian
Geoff wrote: >That's redundant. If this method is in Servlet itself, then simply: > > def isServletSubclass(self): >return 1 Duh. Sorry! Does ths same thing. >My rationale is that this is a fixed property of a particular class, so it >should be a class attribute, rather than a met

RE: [Webware-discuss] Allowing delegation in servlets

2002-04-11 Thread Geoffrey Talvola
Edmund Lian wrote: > Your question does suggest a potential solution though. How we add the > following method in Servlet: > > def isServletSubclass(self): > return issubclass(self, Servlet) That's redundant. If this method is in Servlet itself, then simply: def isServletSubcla

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-10 Thread Edmund Lian
Chuck wrote: >It's unfortunate that Python places so much emphasis on global >functions: > isinstance(obj, Class) > >Over methods: > obj.isinstance(Class) > >Otherwise you could override this easily for your delegation case. Does >isinstance() happen to call one those quadruple

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-10 Thread Chuck Esterbrook
On Wednesday 10 April 2002 04:00 pm, Edmund Lian wrote: > I'm not advocating against inheritance. What I am advocating is that > the type check needs to be able to be turned off, or made a bit more > intelligent. It's unfortunate that Python places so much emphasis on global functions: i

RE: [Webware-discuss] Allowing delegation in servlets

2002-04-10 Thread Edmund Lian
Geoff wrote: >But someone (I can't even remember who started this thread :-)) is >using a Delegation technique to write his servlets and could only >get it to work by removing the check for Servlet as a base class. That someone was me... :-) Here's an example of delegation: In the file that I

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-10 Thread Chuck Esterbrook
On Wednesday 10 April 2002 04:00 pm, Edmund Lian wrote: > Chuck wrote: > >It sounds like the assert should be changed to an "if: raise" to be > >more clear and avoid being "optimized out". > > Maybe so, but regardless of how the type checking is done, I think we > ought to be able to use delegatio

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-10 Thread Edmund Lian
Chuck wrote: >It sounds like the assert should be changed to an "if: raise" to be >more clear and avoid being "optimized out". Maybe so, but regardless of how the type checking is done, I think we ought to be able to use delegation. With autodelegation, all the additional methods that might be

RE: [Webware-discuss] Allowing delegation in servlets

2002-04-10 Thread Geoffrey Talvola
Esterbrook [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, April 10, 2002 6:26 PM > To: Geoffrey Talvola; [EMAIL PROTECTED] > Subject: Re: [Webware-discuss] Allowing delegation in servlets > > > On Wednesday 10 April 2002 01:53 pm, Geoffrey Talvola wrote: > > I would propo

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-10 Thread Chuck Esterbrook
xperienced earlier. It sounds like the assert should be changed to an "if: raise" to be more clear and avoid being "optimized out". -Chuck > > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > Sent: Monday, April

RE: [Webware-discuss] Allowing delegation in servlets

2002-04-10 Thread Edmund Lian
Geoff wrote: >I would propose using "hasattr" to check for the existence of awake, >respond, and sleep, and removing the assert statement. The RuntimeError >that results could have a much better error message than the assert would >give us, anyhow. I think this is a tidier solution that also r

RE: [Webware-discuss] Allowing delegation in servlets

2002-04-10 Thread Geoffrey Talvola
removing the assert statement. I somehow have a feeling that he has an opinion on this, maybe because it was discussed before? - Geoff > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Monday, April 08, 2002 3:31 PM > To: [EMAIL PROTECTED] > Subj

RE: Better API docs? (Was Re: [Webware-discuss] Allowing delegation in servlets)

2002-04-09 Thread Kendall Clark
> "geoffrey" == Geoffrey Talvola <[EMAIL PROTECTED]> writes: geoffrey> Let's not make this a one-off. Instead, pydoc or other geoffrey> documentation tools should be run on the Python source geoffrey> automatically as part of running "python install.py" (or geoffrey> "python setup.py

RE: Better API docs? (Was Re: [Webware-discuss] Allowing delegation in servlets)

2002-04-09 Thread Geoffrey Talvola
Kendall Clark wrote: > jeffrey> 1. Documentation - it would help to see what core set(s) of > jeffrey> methods make up servlet use, and which methods are > jeffrey> particular to special servlet implementations. > > and toward this same end -- > > I think it would help if someone c

Better API docs? (Was Re: [Webware-discuss] Allowing delegation in servlets)

2002-04-08 Thread Kendall Clark
> "jeffrey" == Jeffrey P Shell writes: jeffrey> Anyways, I've found myself wishing that their Interface jeffrey> package was available separately, as it could help Webware jeffrey> a couple of ways: Failing that... jeffrey> 1. Documentation - it would help to see what core set(s) o

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-08 Thread Mike Orr
On Mon, Apr 08, 2002 at 02:43:37PM -0400, Geoffrey Talvola wrote: > > My first attempt failed because line 183 of ServletFactory is: > > > > assert issubclass(theClass, Servlet) > > > > Anyway, I'd like to argue for the removal of the assertion in > > ServletFactory, since it is denying use

Re: [Webware-discuss] Allowing delegation in servlets

2002-04-08 Thread Jeffrey P Shell
On 4/8/02 2:10 AM, "Edmund Lian" <[EMAIL PROTECTED]> wrote: > I've been trying to work around a multiple inheritance issue (the diamond > problem that Python 2.2 solves) with Cheetah, and thought of using > delegation instead of inheritance. > > My first attempt failed because line 183 of Servle