[Twisted-web] simple registry failure - __adapt__

charlie detar chazen at gmail.com
Sat Jan 7 11:48:43 MST 2006


Hi,

I noticed an email from Dickon Reed referencing this issue last June
(http://twistedmatrix.com/pipermail/twisted-web/2005-June/001536.html),
but there is no reply in the archives - I was wondering if someone had
discovered a solution?

I am attempting to write a simple rpi script which uses a registry, as
described in the documentation:
http://twistedmatrix.com/projects/web/documentation/howto/using-twistedweb.html#auto17

My rpy script is as follows:
----
from twisted.web import resource

class Counter:
    def __init__(self):
        self.value = 0
    def increment(self):
        self.value += 1
    def getValue(self):
        return self.value

counter = registry.getComponent(Counter)
if not counter:
   registry.setComponent(Counter, Counter())
counter = registry.getComponent(Counter)

class MyResource(resource.Resource):
    def render_GET(self, request):
        counter.increment()
        return "you are visitor %d" % counter.getValue()

resource = MyResource()
----

I get the following error:

exceptions.AttributeError: class Counter has no attribute '__adapt__'
/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/twisted/web/server.py,
line 152 in process
150    self.postpath = map(unquote, string.split(self.path[1:], '/'))
151    try:
152      resrc = self.site.getResourceFor(self)
153      self.render(resrc)
...

I would be happy to send the full traceback if it would be useful in
identifying the problem.

I am using Twisted, Twisted Web, and Zope Interfaces installed from
the 2005-11-06 Twisted "Sumo" build on an OS X 10.3.9 G5 running
python 2.3 (the latest for OS 10.3.x).

cheers,
Charlie



More information about the Twisted-web mailing list