Wednesday, February 25, 2009

Parameters in python

http://wiki.futuretoby.com/Parameter_List_Chaining_in_Python

Sunday, February 22, 2009

JBoss Cache

JBoss 4.2.3 includes JBoss Cache 1.4.7

Guide to JBoss Cache
http://galder.zamarreno.com/wp-content/uploads/2008/09/hibernate-jbosscache-guide.pdf

http://www.infoq.com/news/2008/06/jboss-cache-interview

http://www.jboss.org/file-access/default/members/jbosscache/freezone/docs/2.1.1.GA/userguide_en/html/transactions.html#d0e3653

Sunday, February 15, 2009

Good T-SQL tutorial

For those of you who would like to know T-SQL

http://www.databasejournal.com/features/mssql/article.php/3087431/T-SQL-Programming-Part-1---Defining-Variables-and-IFELSE-logic.htm

An example T-SQL script


declare @jobId int

declare JobList cursor for select id from tsktask where fkparenttaskid is not null


OPEN JobList
FETCH NEXT FROM JobList INTO @jobId

WHILE @@FETCH_STATUS = 0
BEGIN

declare @parentTaskId int
SET @parentTaskId = (select fkParentTaskId from TskTask where id = @jobId)

declare @runNo varchar(25)
SET @runNo = (select identifier from tsktask where id = @parentTaskId)

update tsktask
set identifier = @runNo
where id = @jobId


FETCH NEXT FROM JobList INTO @jobId
END

CLOSE JobList
DEALLOCATE JobList

In Junit you can group your tests together into a suite, so they can be run altogether. This is useful for running all your module tests in your IDE in the one go, to get a nice overview.

In Junit4 you create a test suite by creating and running a class like example below:



@RunWith(Suite.class)
@SuiteClasses({
ConfigModuleMgmtApiTest.class,
ConfigMgmtApiTest.class,
ConfigHelperTest.class,
DataTypeHelperTest.class
})
public class ConfigTestSuite {

}

Sunday, February 8, 2009

Unable to install Terminal Services ActiveX Client

Trying to login via the POTA portal with IE7. When trying to get a web RDP session to one of the servers, it prompted me to Install the add on "Terminal Services ActiveX Client". I would click "Run ActiveX Control" and then Run when it popped up, but this would just do nothing.

The fix was:

- In IE go to Tools -> Internet Options -> Security (2nd tab) -> Trusted sites.
- Click Sites button and add your Terminal Server's FQDN, or IP. Uncheck "Require server verification (https:) for all sites in this zone" if your server doesn't use https. Click Close.
- Click on the Custom level... button about 1/3rd up from the bottom of the Security Window and scroll down to "Download unsigned ActiveX controls" and change the radio button from Disable to Prompt.
- Click OK and you should be set.

From
http://msmvps.com/blogs/steveb/archive/2007/07/30/blocked-in-ie7-from-connecting-to-your-desktop-in-remote-web-workplace.aspx

Saturday, February 7, 2009

Crazy javascript

What is that InstallFunction doing?
 
function doAdd() {
server
.Add($('num1').value, $('num2').value, onAddSuccess);
}

function InstallFunction(obj, name) {
   obj[name] = function() { Request(name, arguments); }
}

var server = {};
InstallFunction(server, 'Add');


Where Request is a method that encapsulates and simplifies an AJAX call

Friday, February 6, 2009

Things I like about Django Templates

If you use variables, values are automatically escaped.

Python packages

We tried to create packages for our controllers and there is code like below. But I don't want to have to write an import for every class I use, and I don't want to have to put all my classes in one file. I want it to be like Java - you can import a package (a directory) and you get access to all the classes within it.


from controllers.main_page import *
from controllers.book_owning_create import *
from controllers.book_yearning_create import *

application = webapp.WSGIApplication([
('/', MainPage),
('/bookowning/create', BookOwningCreate),
('/bookyearning/create', BookYearningCreate)


What I want to do is


from controllers import *

application = webapp.WSGIApplication([
('/', MainPage),
('/bookowning/create', BookOwningCreate),
('/bookyearning/create', BookYearningCreate)



It seems there is no really easy way to do it (that doesn't involve more typing). Also it seems to general consensus is to group classes in a module (ie. file).

The way I could do it would be to import all those classes in the __init__.py file of the controllers package. Like such:

(in __init__.py)

from book_owning_create import BookOwningCreate
from book_yearning_create import BookYearningCreate

Wednesday, February 4, 2009

Using SUPPORTS transaction attribute doesn't work when a transaction has become inactive

In our message receivers, we are sending an event after an exception has occured.

In our receiver method:

h.handle(message);
} catch (Throwable e) {
logger.error("Error in handling message", ExceptionUtils.getRootCause(e));
MessageProcessingErrorEvent mpe = new MessageProcessingErrorEvent(userManagement.getUserBusUnitGuid(),
e);
mpe.send();
throw new XmRuntimeException(e.toString(),e);
}


The sending of the event fails because we look up the user's busUnitGuid and this requires a transaction. The receiver method is being run in a transaction itself.

I thought one solution to this problem would be to put SUPPORTS transaction attribute on the getUserBusUnitGuid() method. The SUPPORTS attribute says that it will go under a transaction if one is present, otherwise it will run without a transaction.

It didn't fix the problem though, it was still saying that the transaction was inactive. Probably JBoss realised there was a transaction attached, so tried to use it, but then discovered it was inactive.

Monday, February 2, 2009

Hibernate Classpath problems in Eclipse

Getting NoSuchMethodException when trying to run XmLocationInternal test in Eclipse - something about ClassValiditor - I think there was a clashing jar in my JBoss 4.2.3 Client library - after positioning this library after the JBoss 4.2.3 library in my classpath, it worked again.