On 2006-07-17 20:24:06 -0400, John Peacock wrote:
> Peter J. Holzer wrote:
> > Actually, since Qpsmtpd::Address is a hashref, any plugin could just store
> > and retrieve arbitrary information in it. But that's ugly and violates
> > OO principles, so I wouldn't propose that as a general solution.
> 
> If that's the part that makes you queasy, there's two ways around that:
> 
> 1) subclass Qpsmtpd::Address and add your own object methods (you need to hook
> rcpt anyways, so just rebless the object into your own class at the top);

Nice idea. I didn't think of reblessing the object. Could become messy,
if several plugins try to extend Qpsmtpd::Address this way, though.


> 2) somewhat more evil, extend the Qpsmtpd::Address class by adding a new 
> object
> method (using eval in creative ways); we could even make that easier adding a
> method-maker method to Qpsmtpd::Address (or Qpsmtpd.pm for that matter).

:-) I had that idea, too. You don't even need eval:

----snip---------------------------------------------------------------
sub hook_rcpt {
    my ($self, $transaction, $rcpt) = @_;
    $self->log(LOGDEBUG, "the answer for $rcpt is ",
                $rcpt->config("the answer"),
                "\n");  
    return DECLINED;
}
    


package Qpsmtpd::Address;
use Qpsmtpd::Constants;

sub config {
    my ($self, $c, $arg) = @_;
    return 42;
}
----snip---------------------------------------------------------------

        hp

-- 
   _  | Peter J. Holzer    | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR       | > ist?
| |   | [EMAIL PROTECTED]         | Was sonst wäre der Sinn des Erfindens?
__/   | http://www.hjp.at/ |    -- P. Einstein u. V. Gringmuth in desd

Attachment: pgpMmVsli0JEZ.pgp
Description: PGP signature

Reply via email to