← Back to team overview

beeseek-devs team mailing list archive

[Branch ~beeseek-devs/beeseek/trunk] Rev 206: Allow interfaces to require the __slots__ attribute from classes.

 

------------------------------------------------------------
revno: 206
committer: Andrea Corbellini <andrea.corbellini@xxxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2009-02-01 16:53:38 +0100
message:
  Allow interfaces to require the __slots__ attribute from classes.
  Developers now can now require __slots__ to be declared in a class using 
  interfaces. This can be done by setting needslots = True in the 
  interface declaration.
modified:
  beeseek/interfaces.py
  beeseek/network/lowlevel.py
    ------------------------------------------------------------
    revno: 205.1.2
    committer: Andrea Corbellini <andrea.corbellini@xxxxxxxxxxx>
    branch nick: fix-313272
    timestamp: Sun 2009-02-01 16:37:09 +0100
    message:
      Require __slots__ for all protocols.
    modified:
      beeseek/network/lowlevel.py
    ------------------------------------------------------------
    revno: 205.1.1
    committer: Andrea Corbellini <andrea.corbellini@xxxxxxxxxxx>
    branch nick: fix-313272
    timestamp: Sun 2009-02-01 16:36:25 +0100
    message:
      Add a way to expose __slots__ in an interface.
    modified:
      beeseek/interfaces.py

=== modified file 'beeseek/interfaces.py'
--- beeseek/interfaces.py	2009-01-17 16:30:48 +0000
+++ beeseek/interfaces.py	2009-02-01 15:36:25 +0000
@@ -49,6 +49,8 @@
     standard objects.
     """
 
+    needslots = False
+
     def __new__(cls):
         raise TypeError('Cannot directly instance Interface')
 
@@ -99,8 +101,15 @@
 
         for interface in interfaces:
             for name in dir(interface):
-                if name in commons:
+                if name == 'needslots':
+                    if not getattr(interface, name):
+                        continue
+                    name = '__slots__'
+                    value = list, tuple, basestring
+                elif name in commons:
                     continue
+                else:
+                    value = getattr(interface, name)
 
                 # Check if the variable is declared
                 if name not in attrs:
@@ -110,8 +119,6 @@
                             'declared' % (name, interface.__name__),
                             ImplementationWarning, 2)
                     continue
-
-                value = getattr(interface, name)
                 attr = attrs[name]
 
                 if isinstance(attr, MemberDescriptorType):

=== modified file 'beeseek/network/lowlevel.py'
--- beeseek/network/lowlevel.py	2009-01-25 16:32:13 +0000
+++ beeseek/network/lowlevel.py	2009-02-01 15:37:09 +0000
@@ -35,8 +35,7 @@
     must implement this interface.
     """
 
-    # XXX See bug 313272
-    #__slots__ = tuple
+    needslots = True
     closed = int, property, """True if the socket has been closed."""
     peername = tuple, property, """The address of the remote endpoint."""
     family = int, """The socket family."""



--
BeeSeek mainline
https://code.launchpad.net/~beeseek-devs/beeseek/trunk

Your team BeeSeek Developers is subscribed to branch lp:beeseek.
To unsubscribe from this branch go to https://code.launchpad.net/~beeseek-devs/beeseek/trunk/+edit-subscription.