[Twisted-Python] trouble with registering an IModel adapter

Tim Andrews tim.andrews at adpro.com.au
Thu Aug 7 01:38:33 EDT 2003

Hi folks,

I copied the following code from the manual, but keep on getting exceptions.
Any clues?



# Demonstration of registering an IModel adapter
# Copied from "The Twisted Documentation" section 7.3.5
# Raises the following exception:
#   exceptions.AttributeError: MyDataModel instance has no attribute 'orig'

from twisted.web.woven import model, page

template = """
     <h2 model="something" view="Text">something stuff goes here!</h2>

class MyData:
  def __init__(self, something=""):
    self.something = something

class MyDataModel(model.MethodModel):
  def wmfactory_something(self, request):
    return self.orig.something

from twisted.python import components
from twisted.web.woven import interfaces

components.registerAdapter(MyDataModel, MyData, interfaces.IModel)

resource = page.Page(MyDataModel(), template=template)

More information about the Twisted-Python mailing list