Click here to get back home

Plans: New module for event registering and raising.

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Plans: New module for event registering and raising. Lee Standen 04-30-2007
Posted by Lee Standen on April 30, 2007, 4:20 am
Please log in for more thread options


Hi Guys,

I'm about to start work on what should (initially) be a fairly simple
API for allowing modules to register for events within an application. I
think it's best explained with a simple code example, based on the
intended use for this application.

I haven't worked out all the details on this, including how each plug in
will pass back information on why it was unsuccessful, but that should
give you a general idea of my plan.

So, I have a couple of questions:

1. Does anyone know of a package on CPAN that does something similar to
this already?

2. Has anyone considered working on something similar in the past,
and/or have anything they'd like to contribute?

3. (last, but least) any suggestions on the namespace that this would
fall under?

Look forward to your replies :)

Thanks!

----
package Account::Event::Business;
use Account::Event;

Account::Event->register('ACCOUNT_CLOSE', &closeAccount );

sub closeAccount {
        my ($account) = @_;
        if ($account->someproperty eq 'somevalue') {
                return 0; # Not allowed to close
        }
        return 1; # Didn't fail any checks in this plugin
}

----
package Account;
use Account::Event;

sub close {
        my ($self) = @_;
        $self->active(0); # For example;
        if (! Account::Event->raise('ACCOUNT_CLOSE')) {
                $self->rollback;
                die "Can't close account";
        } else {
                $self->commit;
        }
}

__END__

Similar ThreadsPosted
Event-1.03 module March 2, 2005, 4:19 pm
registering name Device::Cdio February 8, 2006, 6:30 pm
Can't locate loadable object for module Tk::Event July 15, 2005, 9:15 am
ANNOUNCE: POE-Event-Message May 11, 2007, 12:41 pm
Start an Event when a Session ends December 20, 2004, 5:57 pm
ANNOUNCEMENT: POE 0.32, an event driven component framework August 6, 2005, 4:29 pm
Lower case module name for non-pragma module January 4, 2005, 10:19 am
RFC: New module 'Module::Bundled::Files' August 26, 2005, 3:49 pm
help with an MD5.pm module!! September 3, 2005, 11:39 pm
Looking for RTP module December 9, 2004, 9:17 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap