On 10/25/05, Kieren Diment <[EMAIL PROTECTED]> wrote:
> On 25 Oct 2005, at 19:56, Aaron Trevena wrote:
>
>
> > On 10/25/05, Kieren Diment <[EMAIL PROTECTED]> wrote:
> >
> >
> >> I'm trying to rig together a fairly minimal Maypole app to look at
> >> the contents of a database. As soon as I try to introduce a :
> >> Exported method into the app I get invalid code attribute errors like
> >> this:
> >>
> >>
> > ... Putting BEGIN { } around the call to
> > setup is one way to take care of this.
> >
> >
>
> This works. Thanks.
>
> And now that I think of it, as this is
>
> a. simple, and
> b. it works
>
> Are there any disadvantages of calling setup in a BEGIN {} block?
> (thinking documentation).
If you are using your own custom model, then calling setup() inside
BEGIN will set up the model on top of Maypole::Model::CDBI, instead of
using the custom model, because setup() is being run at compile time,
whereas you specify a custom model at run time.
Same goes for custom view classes.
I always set up all the config, then call setup() at the very end of
the driver, just in case there are any config settings used in the
setup() of any plugins I'm loading. The opposite of calling it inside
BEGIN.
What Simon is advocating is a way to put model methods into your
driver class. In my opinion, Just Say No. If you must put model
methods from multiple packages in a single file, at least put them in
your custom model, rather than in the driver. Remember, model classes
inherit from Maypole::Model::Base, whereas the driver and plugins
inherit from Maypole.pm. Putting model methods in the driver is
confusing and error prone.
> Presumably writing "use Maypole::Application qw(-Setup);" (given the
> caveats in the Maypole::Application pod )is equivalent?
Almost, but note that you can only do this if you set up all the
config data first. That means using Maypole::Plugin::Config::YAML or
Maypole::Plugin::Config::Apache [0]. You get the equivalent of what I
was advocating - all the config is set up before setup() is called.
d.
[0] Or you could specify the config settings inside a BEGIN block,
placed before the use Maypole::Application statement. But don't do
that ;-)
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Maypole-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-users