[Twisted-web] simple registry failure - __adapt__

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


I noticed an email from Dickon Reed referencing this issue last June
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:

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):
        return "you are visitor %d" % counter.getValue()

resource = MyResource()

I get the following error:

exceptions.AttributeError: class Counter has no attribute '__adapt__'
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).


More information about the Twisted-web mailing list