April 30, 2009 at 9:04 pm
· Filed under Perl
I have to admit it: I broke the 1.02 version of Encode::IMAPUTF7, but I didn’t mean to hide it.
The version have two changes. A code cleanup, which among other minor things make the indentation and coding style consistent, and an RFC compliance fix with a patch from the bug submitter. The patch used the old coding style, so I had to aply it by hand — and in this process I broke some functionality.
Even though I didn’t use his patch, I did thank the original submitter in the changelog. It appears that I shouldn’t have done that. For the last two days he has tried to contact me to get his name removed from the changelog. He even looked up my phone number and probably tried to call me twice and texted me once. Well, version 1.04 just being uploaded have a revised Changes file.
So what can I do to avoid this another time?
The first thing is that I have moved the code to github. This enables contributers to patch the latest version.
The second change is to improve testing. It was quite easy to write test cases for the bug. If I had done that the broken version would never have been uploaded.
I still believe that the phrasing ‘thanks to John Doe’ was right and doesn’t imply blame allocation. But in the future I should at least link to the changeset at github.
Any other recommendation for best practices for writing Changes files without making contributers mad?
Permalink
April 27, 2009 at 3:56 pm
· Filed under Perl
[This is what my lightning talk at Nordic Perl Workshop was supposed to be]
A perfect world would have supported some sort of transactions. Handling email is almost as imperfect as it gets, but sometimes I need to send a mail if and only if some other task succeeds. Looking around CPAN I found dozens of modules for sending mail, but none of them seemed to offer to take real responsibility for sending the mail without trying to send it right ahead.
Making a simple assumption I almost solved my problem: Changing the permissions on existing file should succeed!
The Postfix pickup(8) daemon looks for mail that has been dropped into the maildrop directory. Only files with a the permission bits set to 0744 is feed into the mailsystem. So just write a well formatted file into the maildrop directory and change the permissions when Postfox is permitted the process the mail. This is exactly what Mail::Postfix::Postdrop does. Sending mail with control over the process is simple:
use Mail::Postfix::Postdrop;
my $postdrop = new Mail::Postfix::Postdrop $message;
$postdrop->build; # Build the content of the queue file
$postdrop->write; # Write it to the maildrop queue
$postdrop->release; # Let pickup(8) process the queue file
$postdrop->notify; # Notify pickup(8) about new files (Optional)
The release method is just changing the permissions on the file i the maildrop directory. This way I can almost make sure that Postfix will take responsibility for delivering the mail but still being able to change my mind. Then we just need to wrap it up into some kind of Transaction object. Let us make something up:
package Transaction::Simple;
use Carp;
sub new {
my ( $class, %args ) = @_;
$class = ref $class ? ref $class : $class;
return bless {
commit => $args{commit} || sub { return 1 },
rollback => $args{rollback} || sub { return 1 },
caller => [ caller() ],
handled => 0
}, $class;
}
sub commit {
my $self = shift;
return if $self->{handled};
$self->{handled} = 1;
return $self->{commit}->();
}
sub rollback {
my $self = shift;
return if $self->{handled};
$self->{handled} = 1;
return $self->{rollback}->();
}
sub DESTROY {
my $self = shift;
return if $self->{handled};
carp(sprintf( "Commit object created at %s line %d went unhandled out of scope", $self->{caller}->[1], $self->{caller}->[2] ) );
return $self->rollback;
}
1;
And the we will send mail with the following function:
sub send {
my $message = shift;
my $mail = Mail::Postfix::Postdrop->new($message);
$mail->build();
$mail->write();
return Transaction::Simple->new(
commit => sub { $mail->release(); $mail->notify() },
rollback => sub { $mail->drop() }
}
}
Permalink
April 24, 2009 at 9:00 am
· Filed under Perl
At Nordic Perl Workshop 2009 the Perl Iron Man project was announced by Matt S Trout. The rules are simple: Blog once about Perl every week for half an year.
Well, that’s a challenge. I’m in!
I have been a Perl in-house developer for at least 8 years at almost full time (except for the two years I also did Typo3 development in PHP). So what to expect? Hopefully I will be able to put some live code in most postings. Modern Perl, but probably a bit on the conservative side. But don’t expect long hand waving postings about how the world should be and what the future brings – I will blog about working with Perl today.
I’ll probably write my first real post during the weekend, and then JFDI!
Permalink
April 5, 2009 at 1:47 pm
· Filed under Open source, Perl
Some time ago I bought a .tel domain, just to play with some new technology. Clicking around in some web interfaces does not satisfy me, so I had to do something else.
The main targets for .tel client applications seems to be the iPhone, the Blackberry, and Outlook, but using neither of these I dug deeper at their developer site. Their main API’s are available as SOAP.
Unfortunately I couldn’t get SOAP::Lite to speak with my Tel Hosting Providers SOAP server. So with a lot of handcoding SOAP I have made some small perl modules to access my .tel domain.
At the moment only parts of the Client API is implemented and the Perl API isn’t really stable. But sample scripts to list and change profiles and to set a ‘quote of the day’ are available and working.
Get it at CPAN: http://search.cpan.org/dist/WebService-Telnic/ (wait for version 0.2 to get indexted) or get the bleeding version from github
WARNING: Until release 1.0 I will guarantee that the API will change for each release…
Permalink
April 2, 2009 at 12:24 pm
· Filed under hacking.dk
Atter engang er jeg blevet bedt om at vise mine fede hackerskilz. Denne gang fra en forsmået husbond:
Hvis man skal have hacket nogle sms beskeder? Hvor skal man så henvende sig?
Min kone har smset en del med en anden mand og jeg er ved at dø for at få fat i hvad de har skrevet til hinanden! Kan sådant noget teoretisk lade sig sig gøre?
Jeg ved at det er ulovligt, men !!!
At henvende sig til ejeren af et websted der forklare at hacking ikke bare betyder “En der bruger computere til at gøre noget kriminelt” var ikke det rigtige sted at henvende sig og “men” er sgu nok den dårligeste argumentation for at begå ulovligheder jeg nogensinde har set.
Permalink