perl - Catalyst dispatcher for arbitrary tree-structure -


greetings,

i'm new catalyst , attempting implement dispatch logic.

my database has table of items, each unique url_part field, , every item has parent in same table, making tree structure. if baz child of bar child of foo child of root, want url /foo/bar/baz map object. tree can depth, , users need able access node whether branch or leaf.

i have been looking through documentation chained dispatchers, i'm not sure if can want. seems each step in chained dispatcher must have defined name pathpart attribute, want urls determined solely database structure.

is easy implement existing catalyst dispatcher, or need write own dispatch class?

thanks! :)

eta:

i figured out can use empty args attribute catch arbitrary number of arguments. following seems catch every request under root:

sub default :path :args() {     ( $self, $c ) = @_;      $path = $c->request->path;      $c->response->status( 200 );     $c->response->body( "your path $path" ); } 

from there can manually parse path , need, however, don't know if best way accomplish i'm after.

it depends on structure of data, i'm not clear on question.

if there fixed number of levels (or @ least limited range of numbers of levels) each level corresponding specific sort of thing, chained can want -- it's valid (and downright common) have chained action :captureargs(1) pathpart('') create /*/ segment in path -- is, gobbles 1 segment of path without requiring particular fixed string show up.

if there's not such thing -- e.g. you're chasing unlimited number of levels down arbitrary tree, variadic :args action want, , there's nothing dirty in using it. don't need decoding $c->req->path -- can left-over path segments $c->req->args, or my ($self, $c, @args) = @_; in action. can write new dispatchtype, it's not worth payoff.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -