[Twisted-web] interface.queryDescriptionFor instead of getattr

Andrea Arcangeli andrea at cpushare.com
Sat Dec 17 07:31:13 MST 2005


I noticed a deprecation warning, and I tried to fix it but it breaks
stuff so I backed it out, I post it just in case somebody can make a
right fix for the deprecation warning. This intermediate step between
compy and zope interfaces is very confusing.

Also note I totally dislike interfaces, all of them, no matter if
they're form zope, twisted, nevow.copy or whatever else interface.
They're an huge waste of cpu too, I wish all code was written without
them. Unless I'm absolutely forced by things like nevow, I never use
the interfaces insanity in my code. Perhaps I will change my mind after
I stop seeing all my cpu sucked by them, but at the moment I would never
dream to touch them in my code.

I strongly reccomend people to never use interfaces, they're a bad idea,
language lawyers may appreciate them so they can put to work all
features of python, but if you want your code simple, fast and readable
you should always avoid them.

2005/12/17 15:22 CET [HTTPChannel,0,127.0.0.1]
/home/andrea/bin/x86_64/python/lib/python2.4/site-packages/formless/webform.py:460:
twisted.python.components.ComponentsDeprecationWarning: Don't get
attributes (in this case, '__spec__') off Interface, use
.queryDescriptionFor() etc. instead

Index: configurable.py
===================================================================
--- configurable.py	(revision 3683)
+++ configurable.py	(working copy)
@@ -30,7 +30,7 @@
         for interface in ifs:
             ## TypedInterfaces have a __spec__ attribute which is a list of all Typed properties and
             ## autocallable methods
-            for binding in getattr(interface, '__spec__', []):
+            for binding in interface.queryDescriptionFor('__spec__', []):
                 bindingDict[binding.name] = binding
                 if binding.name not in bindingNames:
                     bindingNames.append(binding.name)
@@ -162,7 +162,7 @@
         bindingNames = []
         self.bindingDict = bindingDict = {}
         interface = self.groupInterface
-        for binding in getattr(interface, '__spec__', []):
+        for binding in interface.queryDescriptionFor('__spec__', []):
             bindingDict[binding.name] = binding
             if binding.name not in bindingNames:
                 bindingNames.append(binding.name)



More information about the Twisted-web mailing list