[rt-devel] Can't call method "make_singlepart" on unblessed reference at /opt/rt3/lib/RT/Attachment_Overlay.pm

Ron rong at israsrv.net.il
Tue Jul 8 20:48:56 EDT 2003


Still fighting the attachment battle I am getting the above error
here is my code in Attachment_Overlay:


 if ( $Attachment->parts ) {
        $id = $self->SUPER::Create(
            TransactionId => $args{'TransactionId'},
            Parent        => 0,
            ContentType   => $Attachment->mime_type,
            Headers => $Attachment->head->as_string,
            Subject => $Subject);

    
    foreach my $part ( $Attachment->parts ) {
        my $SubAttachment = new RT::Attachment( $self->CurrentUser );
            $SubAttachment->Create(
            TransactionId => $args{'TransactionId'},
        Parent        => $id,
        Attachment    => $part,
        ContentType   => $Attachment->mime_type,
        Headers       => $Attachment->head->as_string(),

            );
#######################################################################
#         I added the if statement below to try and create a new html 
attachment for        #
#         every microsoft document that is being attached to this ticket 
                            #
#######################################################################
# Find out if we are attaching a doc file and make an html copy of each doc
       if($Subject =~ /\.doc$/) { # we have a microsoft document attached
        my $html;
        my $fh;
        my $newHtml;
        my $tmpdir;
       
        # try new temporary filenames until we get one that didn't 
already exist
        do { $html = tmpnam() }until $fh = IO::File->new($html, 
O_RDWR|O_CREAT|O_EXCL);
       
        # install atexit-style handler so that when we exit or die,
        # we automatically delete this temporary file
        END { unlink($html) or die "Couldn't unlink $html : $!" }

        # remember the path to the temporary file
        $tmpdir = dirname($html);

        # get the name of the html copy of our document
        ($newHtml = $Subject) =~ s/\.doc$/\.html/;
       
        # use wvHtml (check abiword.org out for details on the word 
importer ....)
        system("wvHtml --targetdir $tmpdir", $Subject, $html) ;

        # build a new MIME Entity object to attach to the ticket
        my $ent = MIME::Entity->build(Type     => "text/html",
                              Path     => $html,
                              Filename => $newHtml);
             
        # Create a new attachment for the html copy
        my $htmlAttachment = new RT::Attachment( $self->CurrentUser );
        #$id = $self->SUPER::Create(
        #    TransactionId => $args{'TransactionId'},
        #    Parent        => 0,
        #    ContentType   => $ent->mime_type,
        #    Headers => $ent->head->as_string,
        #    Subject => $newHtml);
       
            $htmlAttachment->Create(
            TransactionId => $args{'TransactionId'},
            Parent        => $id,
            Attachment    => $ent->body,
            ContentType   => $Attachment->mime_type,
            Headers       => $Attachment->head->as_string(),
                );
        }


And I get the above error... is there anyhing particularly obviousl that 
I am doing wrong here?
I am new to Perl and specifically OO perl (though I have been 
programming C++, SmallTalk and Java for ~9 years now..)

Thanks
Ron.




More information about the Rt-devel mailing list