Home on the web ~ Dan Van Fleet

Information on SoftPro ProForm with some general computer tips and techniques, with a bit of me.

Home on the web ~ Dan Van Fleet - Information on SoftPro ProForm with some general computer tips and techniques, with a bit of me.

It’s IronPython time, looping up the world in Select

imageI've played a bit with IronPython, tonight I decided to dive in a little bit more. Previously I wrote about some tools I built to deal with a couple multiples, like Lots or ParcelID. We created a single line call that returns a properly formatted string dealing with singles or multiple entries. It is called on a line like this:



Those parameters are, sb the stringbuilder to update, then the multiple object with a .Number child field , followed by what to name a single, or multiple, the text to put between multiples, and finally what to tag on the end.

That was all well and good, but it only worked on a couple multiples. We needed a better way, something like  pointers, so we don't have to know what we don't know until we need to know.(follow that and you can probably code) I wondered if IronPython had something that would work. Enter stage left getattr(), an apparently fantastic method that looks quite key to building reusable IronPython tools to create business rules in SoftPro Select.

First let's look at how the method is called, we've added 2 new parameters to the above call. The Child Object and the Child's field name.


So with this line we loop through the TitleInsuranceCalculations, examining the LoanPolicy object and returning the all the Commitment Proposed Insured fields in a custom formatted string.

The code for AddChildText(), which uses other tools I built shows how getattr() was used looks like this.


So let's dive into this for a moment. In lines 31 and 32 we setup a couple control variables. Then We loop up whatever multiple gets sent in. We don't really care if it's a buyer, seller or in this case a Title Calculation.

Line 34 grabs the child object of the current item. That is used in the next line to grab the field off we're interested in.  I was unable to use "LoanPolicy.CommitmentProposedInsured" notation for this, there's probably a way to do that. If not a callback method would deal with Order.multiple.object.object.object.field notation. That will make the method call simpler also. For now with this 8 line module we can globally deal with any multiples field or child object's field.

Now it's time to refactor those AddObjectNumber and AddObjectID methods in DVF Value Tools. These features will be included in the next maintenance release.

IronPython in Select absolutely rocks. We can now loop up any multiple and pick off the details. Fantastic!

If your code looks like this,


I think you should refactor that into reusable modules and call them with one line of code. This is just a peek into getattr() poke around and see what you can find.

That was the most fun I had in 2 hours at work in a long time, well probably from my last IronPython post. Hahaha.

Thanks for visiting! -Dan

To add a tad on this topic. It also requires try catch or try except blocks to properly work in all cases. Simple null checks are not enough here. It's hue to keep in mind we don't know the order objects will be added to a file, our code must deal with any possibility, even goofy ones that exist only for a pico second. The order and frequency your rules run is indeterminate.

Category: SoftPro

Your email address will not be published. Required fields are marked *