[Twisted-Python] trouble with registering an IModel adapter

Tim Andrews tim.andrews at adpro.com.au
Wed Aug 6 23:38:33 MDT 2003


Hi folks,

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

Thanks,

Tim

# 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 = """
  <html>
   <body>
     <h2 model="something" view="Text">something stuff goes here!</h2>
    </body>
  </html>
"""

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