James Kebinger wrote:
Hello all, I've been trying to get access to some Jython objects as
descibed here: http://www.onjava.com/pub/a/onjava/2005/04/27/restweb.html?page=2
. Curious if anyone else has this working, as I'm running into a
couple of problems.
First is that VelocityEngine.UBERSPECT_CLASSNAME is not public in the
copy of Velocity 1.4 I have so I had to replace the call with
ve.setProperty(JythonUberspect.getName()) like this
ve.setProperty("runtime.introspector.uberspect",
JythonUberspect.getName()) - is that to be expected.
Next the code runs without error, except my template will not resolve
my Jython objects - ie $data.field doesn't get expanded as it should.
Digging further, it appears that Velocity is not accessing the
JythonUberspect class at all because replacing the property set above
to garbage makes no difference whatsoever,
I'm using Velocity 1.4, Jython 2.1 and I had to recompile the
JythonUberspect class because it wouldn't initially run on Java 1.4
(invalid class version 49.0...). I'm not running in a web container,
rather a standalone Jython program.
Any one had a similar experience, or can give me a pointer in the
right direction?
thanks
-James
James,
This JythonUberspect stuff is extremely experimental stuff in Velocity.
Somebody can correct me if I'm wrong, but I don't think it's something
that is a stable, supported part of the product.
I think that, for anybody interested in a java template engine that
interacts seamlessly with Jython, FreeMarker is the obvious choice,
since the Jython integration is part of the core distro and has been for
the last couple of years at least. I don't recall any reported problems
with this and at least some people must use it. Of course, if you do run
into any problems, we'd definitely address it since it is a supported
part of the main distro.
Here is the reference to it.
http://freemarker.org/docs/pgui_misc_jythonwrapper.html
Actually, that is slightly inaccurate. Where it says:
"In the very basic case, you only need to call the
public TemplateModel wrap(Object obj);
"
that is not quite right. In the very basic case, you don't need to do
*anything* because the current code is smart enough to call that wrap
method on things like PyNumber and PyString etcetera automagically
behind the scenes.
Anyway, I think this is useful on-topic information.
Regards,
Jonathan Revusky
--
lead developer, FreeMarker project, http://freemarker.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]