On 11/18/05, Dave Howorth <[EMAIL PROTECTED]> wrote:
.
> this roughly equivalent to what would be achieved by:
>
> beerdb/Information/view/about
>
> in standard Maypole (assuming name is your PK)?
>
I think that is partly it . Except name is just any unique key and it
actually goes to a special template, "content/view" . Rather than
view. This is a nice touch i think. Safe and flexible at any rate. A
tad more work. I'v wanted something similar but to actually go to
the view page.
"localhost/internt_service/view/username" and
"localhost/internt_service/username"
Except in my case, this solution would be evil. No subs could be
named after usernames.
But it may be enlightened for other thing. When do you run this? At
setup first and and then every time you create a new row do it in a
trigger. Here is an after create trigger to map a method to every
unique key in the object to the *view* of the object and not
*content/view*.
# set up a view method named after unique key value:
sub evil_teejay_url_mung {
my $self = shift;
foreach my $key ( $$self->unique_keys) ) {
my $name = $self->$key;
next unless defined $name;
my $key_val = $name;
if ($name =~ /^\d+$/ ) {
$name = "_name_" ;
}
# make method
*{__PACKAGE__.'::'.$name} = sub : Exported {
my ($self, $r) = @_;;
my ($content) = __PACKAGE__->search($key => $key_val);
return $r->redirect($self->table . '/view/' . $content->id);
}
}
or something. I think it is real clever Teejay. Nice.
-------------------------------------------------------
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. For more info visit:
http://ads.osdn.com/?ad_idv28&alloc_id845&op=click
_______________________________________________
Maypole-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-devel