logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: extending Mail::Box with the manager?: msg#00010

Subject: Re: extending Mail::Box with the manager?
* Anthony D. Urso (anthonyu@xxxxxxxxx) [040107 16:10]:
> How do I extend Mail::Box such that I still have access to all the manager
> functionality (detemination of mailbox type, etc.), and also still have
> access to mailbox specific methods like loadHead and writeMessages?

The methods you mention are all over the place, so it is a bit
hard to understand what you would like to do exactly.

Nearly all objects which create other objects, like Mail::Box which creates
Mail::Message's, have instantiation options to configure different classes
to be produced.

   my $f = Mail::Box::Mbox->new(folder => ..., message_type => 'my::own');

   package my::own;
   use base 'Mail::Box::Mbox::Message';

This is also possible with the manager (untested code)

   $mgr->open(...., message_type => 'my::own');

because all additional options are passed to Mail::Box->new

>   sub write { my $self = shift; do stuff...; $self->SUPER::write(@_) }
> 
> It would seem to me that polymorphism should make this work; however,
> attempting to call $mbox->write dies stating that MyMail::Box does not
> implement writeMessages(), which I have no desire to implement.  

Yes you do ;-)
The actual work is done in writeMessages, not in write().  The user
calls $f->write()... then some general checks are performed, and some
options parsed.  Then the folder type specific writeMessages() is called
to do "the thing".  So don't extend write() itself unless you need
changes in configuration possibilities for the user.

This is also true for append -- appendMessages, copy & move -- copyMessages,
updage -- updateMessages, read -- readMessages, etc... especially designed
to keep the interface as compatible as possible between various folder
implementations.
-- 
               MarkOv

------------------------------------------------------------------------
drs Mark A.C.J. Overmeer                                MARKOV Solutions
       Mark@xxxxxxxxxxxx                          solutions@xxxxxxxxxxxx
http://Mark.Overmeer.net                   http://solutions.overmeer.net




<Prev in Thread] Current Thread [Next in Thread>