Re: [Zope-dev] Defining Interfaces

2002-01-30 Thread Toby Dickenson

On Wed, 30 Jan 2002 10:08:35 -0700, Jeffrey P Shell
[EMAIL PROTECTED] wrote:

 Or, if you were defining the interface in IDL (mmm,
 almost-avoiding-redundancy through acronyms!) with the target language being
 Python, would you include self?
 
 But what if you were defining an interface as a Python class, with the
 target language being anything except python. Would you include
 self?

I'm saying that you wouldn't.  The point of IDL/ISL is that you wouldn't,
because the interface that you're specifying is independent of the target
language.

Perhaps you misread. I agree the specification is independant of the
target language. I agree that the content of the specification should
be independent of the specification language.

However, Im sure you agree that the text of the specification is
intimitely dependant on the specification language.

Using python classes as the specification language, but not including
the 'self', seems (IMHO) to be as crazy as using C++ classes as the
specification language but not using curly brackets.

 I think my conclusion here is that using python classes to define
 interfaces may be counterproductive.

It may be the best we have (it's best understood by the target development
audience)

As a product author I thought I *was* the target audience.

..[1] http://python.sourceforge.net/peps/pep-0245.html

A good reference, thanks

Toby Dickenson
[EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists -
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-29 Thread Phillip J. Eby

At 03:17 PM 1/28/02 +, Chris Withers wrote:
Jeffrey P Shell wrote:
 
  On 1/27/02 11:25 AM, Steve Alexander [EMAIL PROTECTED] wrote:
 
   Hi folks,
  
   When I define an Interface, are the methods of the interface supposed to
   have self as the first argument?
 
  No.

Can you expand on this a little?

It doesn't make sense to me to exclude 'self'...

Because when you *call* the methods, you don't pass 'self', it's 
implied.  Since an interface is supposed to document the call signature, it 
actually doesn't make sense for it to include 'self', since it's not part 
of the call signature.  Make sense?


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-29 Thread Florent Guillaume

  When I define an Interface, are the methods of the interface supposed to
  have self as the first argument?
 
 No.

But this does preclude automatic validation of the contract using
python inheritance from the Interface, doesn't it ? Or will there be
another way ?

Florent
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 10  http://nuxeo.com  mailto:[EMAIL PROTECTED]

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-29 Thread Martijn Pieters

On Tue, Jan 29, 2002 at 07:47:46PM +, Florent Guillaume wrote:
   When I define an Interface, are the methods of the interface supposed to
   have self as the first argument?
  
  No.
 
 But this does preclude automatic validation of the contract using
 python inheritance from the Interface, doesn't it ? Or will there be
 another way ?

No, the validation methods take into account that class members of an
implementation will have a self-referential first argument. Detecting if an
implementation is a class is trivial.

-- 
Martijn Pieters
| Software Engineer  mailto:[EMAIL PROTECTED]
| Zope Corporation   http://www.zope.com/
| Creators of Zope   http://www.zope.org/
-

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-28 Thread Chris Withers

Jeffrey P Shell wrote:
 
 On 1/27/02 11:25 AM, Steve Alexander [EMAIL PROTECTED] wrote:
 
  Hi folks,
 
  When I define an Interface, are the methods of the interface supposed to
  have self as the first argument?
 
 No.

Can you expand on this a little?

It doesn't make sense to me to exclude 'self'...

cheers,

Chris

___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-28 Thread Adrian Hungate

This is based on the new Python 2.2 stuff, isn't it? I would guess the
answer would be You exclude the 'self' first arg in a class method.
Unfortunately I am still trying to digest what has changed in Python 2.2, so
I am probably not the best person to answer beyond this point. There was a
link on here (Or was it -announce) to the change docs for 2.2, that might
give you some pointers.

Adrian...

--
The difficulty of tactical maneuvering consists in turning the devious into
the direct, and misfortune into gain.
- Sun Tzu


- Original Message -
From: Chris Withers [EMAIL PROTECTED]
To: Jeffrey P Shell [EMAIL PROTECTED]
Cc: Steve Alexander [EMAIL PROTECTED]; zope-dev [EMAIL PROTECTED]
Sent: Monday, January 28, 2002 3:17 PM
Subject: Re: [Zope-dev] Defining Interfaces


 Jeffrey P Shell wrote:
 
  On 1/27/02 11:25 AM, Steve Alexander [EMAIL PROTECTED] wrote:
 
   Hi folks,
  
   When I define an Interface, are the methods of the interface supposed
to
   have self as the first argument?
 
  No.

 Can you expand on this a little?

 It doesn't make sense to me to exclude 'self'...

 cheers,

 Chris

 ___
 Zope-Dev maillist  -  [EMAIL PROTECTED]
 http://lists.zope.org/mailman/listinfo/zope-dev
 **  No cross posts or HTML encoding!  **
 (Related lists -
  http://lists.zope.org/mailman/listinfo/zope-announce
  http://lists.zope.org/mailman/listinfo/zope )



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-28 Thread Steve Alexander

Adrian Hungate wrote:
 This is based on the new Python 2.2 stuff, isn't it? I would guess the
 answer would be You exclude the 'self' first arg in a class method.

Not really. You exclude the self first argument of a static method. 
The first argument of a class method is where the class is passed.

The reason that self is now excluded when defining interfaces comes 
from considering who reads interface definitions.

By their nature, interfaces are meant to be read from the outside; 
from beyond the facade. The self attribute of methods is an 
implementation detail, and is not a concern of those who make calls on 
an interface.

With Python2.2, you can demonstrate this by defining a class that has 
static methods only, but which still satisfies some interface 
definition. The self argument need not occur at all.

--
Steve Alexander


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-28 Thread Jeffrey P Shell

On 1/28/02 8:17 AM, Chris Withers [EMAIL PROTECTED] wrote:

 Jeffrey P Shell wrote:
 
 On 1/27/02 11:25 AM, Steve Alexander [EMAIL PROTECTED] wrote:
 
 Hi folks,
 
 When I define an Interface, are the methods of the interface supposed to
 have self as the first argument?
 
 No.
 
 Can you expand on this a little?
 
 It doesn't make sense to me to exclude 'self'...

Jim [Fulton] explained it to me once.  He can explain it better than I can.
But think of it this way -- theoretically, an interface can be implemented
by a folder full of Python scripts as [relatively] easily as it can be
implemented by a class.  Should you then include all of the binding options
(context, container, etc)?

Or, if you were defining the interface in IDL (mmm,
almost-avoiding-redundancy through acronyms!) with the target language being
Python, would you include self?

An interface defines a contract on the usage of an object/component; it's
not necessarily a specification on how to implement it.  The concept of
'self' as the first argument for instance methods is a product of
implementing in a Python class (not to mention that 'self' is not a required
name, just an extremely common convention.  You could use 'this' just as
easily).  

The big theory behind most component models is that the implementation
shouldn't matter so long as certain interfaces are satisfied.  And the
following simple interface could be satisfied a number of ways in Zope
already - by a normal Python class implementation; by a folder with a Python
Script or External Method; by a ZClass with the same; or (in Python 2.2) by
a class with a static method (which would have no 'self').

class ISubscriber(Base):
 Subscriber base interface 
def EventService_inform(event):
 Informs the subscriber that the event has occurred 

-- 
Jeffrey P Shell 
www.cuemedia.com



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



[Zope-dev] Defining Interfaces

2002-01-27 Thread Steve Alexander

Hi folks,

When I define an Interface, are the methods of the interface supposed to 
have self as the first argument?

It certainly seems that way from 
./lib/python/AccessControl/IUserFolder.py in Zope2.  It also seems that 
way from the Interface Interface.

However, many of the interfaces in Zope3 omit the self argument.


--
Steve Alexander




___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-27 Thread Jeffrey P Shell

On 1/27/02 11:25 AM, Steve Alexander [EMAIL PROTECTED] wrote:

 Hi folks,
 
 When I define an Interface, are the methods of the interface supposed to
 have self as the first argument?

No.

 It certainly seems that way from
 ./lib/python/AccessControl/IUserFolder.py in Zope2.  It also seems that
 way from the Interface Interface.
 
 However, many of the interfaces in Zope3 omit the self argument.

-- 
Jeffrey P Shell 
www.cuemedia.com



Sent using the Entourage X Test Drive.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-27 Thread Steve Alexander

Jeffrey P Shell wrote:
 On 1/27/02 11:25 AM, Steve Alexander [EMAIL PROTECTED] wrote:
 
 
Hi folks,

When I define an Interface, are the methods of the interface supposed to
have self as the first argument?

 
 No.

In which case, perhaps we should change InterfaceInterface and 
InterfaceBaseInterface from Interface/iclass.py to reflect this.

The ZDG should also be updated to reflect this, as the example is wrong.

   http://www.zope.org/Documentation/ZDG/ComponentsAndInterfaces.stx

  from Interface import Base

   class Hello(Base):
The Hello interface provides greetings. 

   def hello(self, name):
Say hello to the name 

   class HelloComponent:

   __implements__ = Hello

   def hello(self, name):
   return hello %s! % name


Shall I throw this into the Collector?

--
Steve Alexander



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-27 Thread Jeffrey P Shell

On 1/27/02 3:09 PM, Steve Alexander [EMAIL PROTECTED] wrote:

 In which case, perhaps we should change InterfaceInterface and
 InterfaceBaseInterface from Interface/iclass.py to reflect this.
 
 The ZDG should also be updated to reflect this, as the example is wrong.
 
  http://www.zope.org/Documentation/ZDG/ComponentsAndInterfaces.stx
 
 from Interface import Base
 
  class Hello(Base):
   The Hello interface provides greetings. 
 
  def hello(self, name):
   Say hello to the name 
 
  class HelloComponent:
 
  __implements__ = Hello
 
  def hello(self, name):
  return hello %s! % name
 
 
 Shall I throw this into the Collector?

Probably.  I made a comment on the page itself, just a couple of days ago,
but it's unknown how often those comments are reviewed:


 jshell - Jan. 24, 2002 12:56 pm - This should all be updated to reflect where
 interfaces are going for Zope 3. First, the interface should be named
 IHello, and there should be no 'self' in the signature for the 'hello()'
 method. 


-- 
Jeffrey P Shell 
www.cuemedia.com



Sent using the Entourage X Test Drive.


___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )



Re: [Zope-dev] Defining Interfaces

2002-01-27 Thread Chris McDonough

  Shall I throw this into the Collector?

 Probably.  I made a comment on the page itself, just a couple of days ago,
 but it's unknown how often those comments are reviewed:

They're not reviewed often by the editors, but they sure help folks who read
them in the meantime, so I encourage folks to add comments to the Dev Guide
when possible.

- C



___
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )