[Twisted-Python] (no subject)

Tim Andrews tim.andrews at adpro.com.au
Wed Jul 16 18:41:46 MDT 2003


Hi twisted,

I've just started playing with twisted and am keen to get something
happening with  LivePage. I can serve pages quite happily from an .rpy and
have tried to follow the examples from the manual to get event handlers and
LivePage happening.  When my page is generated "MyController.handle" gets
called, but "MyController.setUp" never gets called.  If I add an "__init__"
method it gets called, but when I try to call "self.view.addEventHandler" it
complains that self.view is a NoneType.

I have also tried subclassing input.Anything, but suffer from a similar
problem in that my "initialize" method never gets called or if I call
"input.Anything.__init__" then I still have a problem with
"self.view.addEventHandler"

FYI I'm running twisted 1.06 on Python 2.2 on a Windows 2000 box

My code for your perusal ...

from twisted.web.woven import page, controller

model = {
    'name': 'fred',
    'stuff': ['Foo', 'Bar', 'Baz']
}

template = """
  <html>
  <body>
  <h3 model="name" view="Text"  controller = "foo"/>
  <div model="stuff" view="List">
  <li pattern="listItem" view="Text"/>
  </div>
  <span view="webConduitGlue" />
  </body>
  </html>
"""

class MyController(controller.Controller):

#  def __init__(self, *args, **kwargs):
#    controller.Controller.__init__(self, args, kwargs)
#    self.view.addEventHandler("onmouseover", self.mouse) # self.view =
NoneType :(

  def setUp(self, request, *args):
    print "setUp" # this never happens :(

  def handle(self, request):
    print 'handle' # this happens :)

  def mouse(self, request, widget):
    print 'Mouse Over!!!'


class MyPage(page.LivePage):

  def wcfactory_foo(self, request, node, model):
    print 'foo factory' # this happens :)
    return MyController(model)


resource = MyPage(model, template=template)


Thanks,

Tim


----------------------------------------
Tim Andrews
Principal Hardware Engineer

Vision Fire and Security
14 Park Way, Technology Park
Mawson Lakes, S.A. 5095

ph: +61-8-84621201
fax: +61-8-84621001
email: Tim.Andrews at adpro.com.au
web site: www.adpro.com.au

----------------------------------------
IMPORTANT ? This email and any attachments may be confidential. Any
retransmissions, dissemination or other use of these materials by persons
or entities other than the intended recipient is prohibited. If received in
error, please contact us and delete all copies. Before opening or using
attachments, check them for viruses and defects. Our liability is limited
to resupplying any affected attachments. [Any representations or opinions
expressed in this e.mail are those of the individual sender, and not
necessarily those of Vision Systems Limited].
--------------------------------------------





More information about the Twisted-Python mailing list