On 1/25/06, Matthew Adams <[EMAIL PROTECTED]> wrote:
> Hello Maypole users:
>
> Quick question here. I've got a number of methods that aren't necessarily
> related to a table class from MyApp::Model::CDBI and I don't want to put
> them under one of my MyApp::TableClass namespaces.
>
> Basically I'd like to say something like:
>
> # Because I haven't a clue what to call these things
> MyApp::Generic;
>
> sub forgot_password() :Exported
> {
> # E-mail the user their password
> # because they went and forgot it again
> }
>
> Now I'm obviously going to have to write my own MyApp::parse_path() so
> that http://myserver/forgot_password maps to
> MyApp::Generic::forgot_passowrd but that isn't the hard bit.
>
> The hard bit is figuring out how to include forgot_password() into the
> Maypole world that I have throughout the rest of MyApp (i.e. I'd like to
> be able to put those nice little attributes on subs and whatnot).
>
> Any thoughts or suggestions would be greatly appreciated!
>
Hi. Here is post from mail a while ago on list. It should help. I have
made this work. Try the patch and then overriding the "class_of"
method in your base class so that it will return a class based on the
"table" in the url. Your table less class should inherit from your
base class. HTH. Just shoot if you have any more questions. P.S. you
can google to get the whole discussion from the archives maybe. I
pulled this out of my mail box.
Maypole tries to fetch_objects for the model_class every request.
This is not good say if the model_class does not correspont to a
table. Here is a patch for Maypole::Model::CDBI fetch_objects so it
wont fetch objects unless the class has primary columns.
Here is the new sub . No need for diff. I labeled changes
sub fetch_objects {
my ($class, $r)[EMAIL PROTECTED];
#my @pcs = $class->primary_columns;
my @pcs = eval { $class->primary_columns }; # pjs
return unless @pcs; #pjs
if ( $#pcs ) {
my %pks;
@[EMAIL PROTECTED](@{$r->{args}});
return $class->retrieve( %pks );
}
return $class->retrieve( $r->{args}->[0] );
}
I was just experimenting with making my custom $r->config->model base
class which does not have a table associated with it. execute an
action. With this patch an override of "class_of" I can say:
localhost/model_class/quick_search
It is desireable to be able to have actions in classes without tables
and have uri s map to classes without tables.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Maypole-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-users