2010/6/10 see <[email protected]>: > Today I (again) tried to use web.py running with Jython. I do not use > the web.py templating but XSLT 2 (via Saxon) instead which is also the > reason to use Jython at all... > > I had to do two hacks in web.py, maybe it would be possible to add > them to the code itself? > > > 1. removed usage of compiler module > > I simple removed these lines in template.py (~line 941) as Jython has > no compiler module. Guess as long as no templating is used this would > be fine? > > # make sure code is safe > # import compiler > # ast = compiler.parse(code) > # SafeVisitor().walk(ast, filename) > > Maybe one could rewrite it as > > try: > import compiler > except ImportError, e: > # alert the user that templating won't work properly > else: > ast = compiler.parse(code) > SafeVisitor().walk(ast, filename) > > > 2. Reloader does not work so simple removed it > > In application.py ~line 652 I added a simple "return" and web.py > works. Reloader does not work obviously as it does not check any > modules. Is there any way to prevent web.py to use it in the first > place? > Problem is in line 654 mtime = os.stat(mod.__file__).st_mtime which > seems to raise a different (Java) exception when mod.__file__ is None. > One could as a catch all except or check for None before trying? > I guess this really is a Jython bug which probably should simple raise > one of the catched (AttributeError, OSError, IOError) but that change > will probably take sooome time... > > > Another annoying issue is that when defining the URL mapping like > > URLS = ( > r'/(.*?)\/?', 'pkg.mod.Handlerclass' > ... > ) > > Jython is unable to import pkg.mod. If pkg import mod itself which in > Python is not needed this does work though. Again a Jython issue I > guess but this time easier to work around in the actual application. > > > Otherwise web.py and Jython work just fine. Being able to use an XSLT2 > processor like Saxon in Jython (sadly no one available for Python...) > is really nice. > > Any chance the two compatibility workarounds could be added to web.py?
Yes. I think it will be nice to make web.py apps run on Jython. Anand -- You received this message because you are subscribed to the Google Groups "web.py" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
