You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Bob Brahms <bb...@pacbell.net> on 2003/01/10 23:32:41 UTC

NEWBIE: getting TDK 2.2 and jython 2.1 to work?

First of all, I'm a total newbie to Turbine and TDK, so please forgive me if
I'm doing or omitting something silly.

I've read the python-howto.html, and done most of what it mentions, but
there is one point I don't understand.

What does the "prepare and compile" section of this mean:
>The first thing is to download JPython from www.jpython.org and copy the
> jpython.jar file into your turibe/lib directory. Now you need to prepare
and
> compile the jpython files like this: build prepare-python build jar This
will
> create a new turbine library that contains the Python code. You need to
copy
> this new .jar file to your application's lib directory.

I looked in my turbine-2.2.jar file and it has
org.apache.turbine.services.assemblerbroker.util.python.PythonScreenFactory
and
org.apache.turbine.services.assemblerbroker.util.python.PythonActionFactory
so I assume that's good enough.

I was able to obtain jython-2.1.jar, and I put it into my tdk-2.2/tdk/lib
directory and
into tdk-2.2/webapps/myapp/WEB-INF/lib.

in my webapps/myapp/WEB-INF/conf/TurbineResources.properties file I have:
services.AssemblerBrokerService.screen=org.apache.turbine.services.assembler
broker.util.python.PythonScreenFactory
services.AssemblerBrokerService.action=org.apache.turbine.services.assembler
broker.util.python.PythonActionFactory
services.AssemblerBrokerService.python.path=WEB-INF/src/python



in WEB-INF/src/python/config.py:
>import java
>
>from java.io import *
>from java.util import *
>
>sys.add_package("org.apache.turbine.modules.screens")
>sys.add_package("org.apache.turbine.modules")
>sys.add_package("org.apache.turbine.util.db")
>sys.add_package("org.apache.turbine.util")
>sys.add_package("org.apache.turbine.services.security.TurbineSecurity")
>sys.add_package("org.webmacro.servlet")
>
>
>from org.apache.turbine.modules.screens  import VelocityScreen
>from org.apache.turbine.modules          import Action
>from org.apache.turbine.util.db          import Criteria
>from org.apache.turbine.util             import RunData
>from org.webmacro.servlet                import WebContext
>from org.apache.turbine.services.security   import TurbineSecurity


I have a test.py in WEB-INF/src/python/screens which has:

>java.lang.System.out.println( "HI THERE from python");
>class Test(VelocityScreen):
>	def doBuildTemplate(self, data):
>		java.lang.System.out.println( "HI THERE from python");
>		context=self.context(data)
>		context.put("me", "Leon")
>		context.put("text", "PythonYEAH")
>		entry_id = data.getParameters().getInt("companyid")
If this class is named something other than Test, I get the same behavior.
The example in the howto uses webmacro, but this seems like what should be
there with Velocity.


I have a Test.vm in my templates/app/screen directory which says:
>$page.setTitle("Test")
>$page.setBgColor("#ffffff")
><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
></head>
><body bgcolor="#ffffff" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0">
>
>Hello
>#if($me)
>   #entryCell ($me)
>#end
>
></body>


when I do http://localhost:8080/myapp/servlet/myapp/template/Test.vm

I get a page that says "Hello".
I don't get any console messages, like I do with println from my java screen
modules.  It looks like the python code is just not getting invoked at all.

Any ideas?

Thanks

bob








--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>