[Twisted-Python] Re: help, my woven web app won't work on win32 but will on linux!

Oisin Mulvihill oisin at enginesofcreation.ie
Sun Jul 20 06:31:31 MDT 2003


Hi,

Well I have had various comments that the code I attached
does not work at all. I tried it on my osx machine with the
twisted 1.0.6 and Twisted-1.0.7alpha2 and found my code
didn't work on windows and linux machines. My suse linux
machine has Twisted-1.0.5 and this is the only machine on
which my program works. I installed 1.0.5 on my osx machine
and low and behold my program works.

I decided to try the "Page in depth" example on which my code
is based to see if I could track the problem. The index.rpy contains
this example. This example does not now work in 1.0.6 and
1.0.7alpha.

When you run this example with 1.0.5 and you can click on the
"fred" or "bob" link you get the following urls and the example
works:

http://localhost:20808/fred
http://localhost:20808/bob

This is what the woven page in depth documentation says and
it works.

If you run this example with 1.0.6/7 you get "resource not found"
error. If however you go to the following url first

http://localhost:20808/index.rpy/

and then click on the "fred" or "bob" link, you get the follow urls
and the example works:

http://localhost:20808/index.rpy/fred/
http://localhost:20808/index.rpy/bob/

This is not what the documentation says should happen. This
appears to be a bug in the new twisted versions. Has something
changed, that means woven child page methods no longer work,
as they did in twisted 1.0.5.

Can someone please shed some light on this?

Thanks,

om




Oisin Mulvihill wrote:

> Hi,
>
> I've produced a small model of my program which hightlights
> the problem I'm having. Attached are two files main.py and
> index.rpy. To run the web app run main and make sure index.rpy
> is in the same directory. Then point your web browser to
> http://localhost:20808
>
> On linux I can click on the web buttons and the app works
> fine. One windows (I'm using win2k) I simply get
> "No Such Resource, File not found".
>
> The button press issues a post and this shows up as the url
> "http://localhost:20808/control?action=set_view&view=view1"
>
> When you look at the MyPage class in index.rpy I have a
> wchild_control method. This method is called on linux and
> I then process the request and take the required action.
>
> On windows the wchild_control method does not appear to be
> called at all and I don't know why.
>
> Can anyone shed any light on this problem?
>
> Thanks,
>
>
> om
>
> ------------------------------------------------------------------------
>
> import time import urlparse import twisted.web.server from 
> twisted.web.woven import view from twisted.web.woven import page from 
> twisted.web.woven import model from twisted.web.woven import input 
> from twisted.web.microdom import lmx from twisted.web.woven import 
> widgets from twisted.web.woven import controller from twisted.python 
> import components # # Set up the session I'll be using: # class 
> IPreferences(components.Interface): pass class 
> Preferences(components.Adapter): __implements__ = IPreferences 
> components.registerAdapter(Preferences, twisted.web.server.Session, 
> IPreferences) class MyModel(model.MethodModel): """ """ pass class 
> NavigationControlsDisplay(view.View): template = """
>
>  
>  
> """ class View1(view.View): """ """ template = """
>
> View One
>
> """ class View2(view.View): """ """ template = """
>
> View Two
>
> """ class MyPage(page.Page): """ """ template ="""
> """ def wvfactory_current_view(self, request, node, model): 
> print("cafemonitor.CafePage.wvfactory_current_view") prefs = 
> request.getSession(IPreferences) view = getattr(prefs, 
> 'current_view','live_view') print("Selecting view <%s>." % view) if 
> view == "view1": print("Returning View1.") return View1(model) elif 
> view == "view2": print("Returning View2.") return View2(model) else: 
> print("unknown view <%s>. Returning View1." % view) return 
> View1(model) def wchild_control(self, request): """This is a fake 
> /control subdirectory used to control a specific machine. request - 
> action: new, complete, void, restore. """ print("wchild_control - 
> request.args <%s>." % str(request.args)) action = 
> request.args.get("action", 0)[0] if action == "set_view": prefs = 
> request.getSession(IPreferences) view = request.args.get("view", 0)[0] 
> print("Setting new view from navigation menu selection <%s>." % view) 
> prefs.current_view = view else: print("unknown action <%s>." % action) 
> return self resource = MyPage(MyModel()) 
> resource.setSubviewFactory("navigation", NavigationControlsDisplay)
>
>------------------------------------------------------------------------
>
>#!/usr/bin/env python
>from twisted.internet import reactor
>from twisted.internet.app import Application
>from twisted.web import static, server, script
>
>def main():
>	"""Run the xml rpc server.
>	"""
>	app = Application("CafeMonitor")
>
>	root = static.File("./")
>	root.processors = {
>		'.rpy': script.ResourceScript,
>		}
>
>	app.listenTCP(
>		port=20808,
>		factory=server.Site(root),
>		interface="localhost"
>	)
>	print("Web Frontend - <%s:%s>." % ("localhost", "20808"))
>	app.run(0)
>	
>if __name__ == '__main__':
>	main()
>	
>  
>

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: main.py
URL: </pipermail/twisted-python/attachments/20030720/844266e4/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: index.rpy
URL: </pipermail/twisted-python/attachments/20030720/844266e4/attachment-0001.ksh>


More information about the Twisted-Python mailing list