Hi All,

The context for this is trying to get ParsedXML 1.5 running on Zope 2.12 
under Python 2.5 (don't ask why!)

Anyway, ParsedXML has a class:

class ManageableNodeList(ManageableWrapper, DOMProxy.NodeListProxy,
     "A wrapper around a DOM NodeList."
     meta_type = "Manageable NodeList"

     # redefine to get back the [] syntax with acquisition, eh?
     def __getslice__(self, i, j):
         return self.wrapNodeList(self._node.__getslice__(i,j))

     # redefine to get back the [] syntax with acquisition, eh?
     def __getitem__(self, i):
         return self.wrapDOMObj(self._node.__getitem__(i))

If you try and iterate over an instance of this class, you get an 
AttributeError: __iter__. This doesn't make a lot of sense, since you 
*don't* get an error like that if you iterate over an instance of:

class X:
   def __getitem__(self,i):
     return 1

I'm wondering there's some ExtensionClass or similar weirdness happening 

(It didn't used to happen under Zope 2.9/Python 2.4)



PS: I have a f'ing horrible workaround for how:

     def __iter__(self):
         return SillyIterator(self)

class SillyIterator:
     def __init__(self,mnl):
         self.mnl = mnl
         self.i = 0

     def next(self):
             e = self.mnl[self.i]
         except IndexError:
             raise StopIteration
         return e
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk
Zope-Dev maillist  -  Zope-Dev@zope.org
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to