Archive for August, 2006

Jon Udell, Jim Hugunin and IronPython.

Wednesday, August 30th, 2006

I find IronPython to be extremely useful. I use it quite a bit to script interactions with IIS servers that use Windows authentication: you get all the power of Python with the authentication transparency of .NET. But I haven’t done anything very involved.

Jon Udell posted a screencast of an interview with Jim Hugunin that really illustrates what you can do with IronPython. Packed into a 38 minute screencast:

  • Changing Avalon UI elements
  • Python integration in Visual Studio
  • Using IronPython to script elements from PowerShell
  • Calling the IronPython library from Visual Basic script.

Getting Started with Ruby

Sunday, August 27th, 2006

I decided to start checking out Ruby on Rails. Well, I installed Ruby on Rails and started learning Ruby.

I haven’t done much of anything yet. Here is some sample Ruby playing around:

>> 1.0/0
=> Infinity
>> 1/0
ZeroDivisionError: divided by 0
from (irb):27:in `/’
from (irb):27
>> 1/0.0
=> Infinity

Here is the Python equivalent:

>>> print 1/0
Traceback (most recent call last):
File “”, line 1, in ?
ZeroDivisionError: integer division or modulo by zero
>>> print 1/0.0
Traceback (most recent call last):
File “”, line 1, in ?
ZeroDivisionError: float division
>>> print 1.0/0
Traceback (most recent call last):
File “”, line 1, in ?
ZeroDivisionError: float division

I don’t understand why 1/0.0 is Infinity in Ruby. I know that it’s a float, so it’s probably being handled differently, but if 1/0 results in a ZeroDivisionError for integer arithmetic, why does the equivalent float division return Infinity? Anybody know?

Calling Methods from the JSTL Core Tag

Wednesday, August 16th, 2006

Well, not really. Recently I was wrestling with a framework that put a bean in the request context. The standard way of outputting the variable was using the Core “out” tag.

I needed to conditionally output some text on the page depending on the value of some of the members of the bean. I didn’t want to copy/paste the same statement all over the page. If I have a bean that has all the data, it makes sense to put that logic in the bean.

But, you can’t call a method from within a tag. You can, however, do it within a Java expression. You can also access variables from the Core tags from Java expressions by using the pageContext variable. So, you can do something like:

<%= pageContext.getRequest().getAttribute("foo") %>

to display the variable.

That’s kind of messy, though, to splatter all over your page. Plus, you get back an Object, so casting to your bean class and calling the method won’t be much less code than copy/pasting “c:if” tags around.

The cleanest way I have found thus far is to do all the dirty casting work in a scriptlet. Start with retrieving the variable from the page context, cast it to your object, and use reference this var in your page where you need to call the method.